+ 2
How can I use try catch with data string in C#?
C#
3 Respuestas
+ 1
Simply wrap you operations with string in try catch block. Make sure you can use Exception class because of its base class for all exceptions. But if you decided to use try catch its a good practice to use more specific classes, like IndexOutOfRangeException and etc.
try{
//you operations for example:
var str = "hello";
var test[8];//exception is here
}catch(IndexOfOurRangeException e)
{
//process or log etc...
}
+ 1
What are you mean "data string" ?
0
try
{
datastring = "do any assignment here"
}
catch(exception ex)
{
//Log(ex.message)
}
Something like this ?