+ 2

How can I use try catch with data string in C#?

C#

9th Dec 2019, 8:35 PM
Carlos Rodriguez
Carlos Rodriguez - avatar
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... }
9th Dec 2019, 10:36 PM
Nikita Galchenko
Nikita Galchenko - avatar
+ 1
What are you mean "data string" ?
10th Dec 2019, 11:01 AM
id001x
id001x - avatar
0
try { datastring = "do any assignment here" } catch(exception ex) { //Log(ex.message) } Something like this ?
9th Dec 2019, 9:06 PM
sneeze
sneeze - avatar