Parsing values in .NET
While converting or parsing values we need to provide the variable to convert and datatype to be converted into String
We will see here the difference between
1 Convert.ToString()
2 .ToString()
While handling null values it is suggested to use always Convert.ToString() method
For ex: Convert.ToString(name)
If your variable is going to have null or an empty value than .ToString() method will generate an exception
For ex :name.ToString()
So it is better to use the first method always instead on the second one in to avoid the exception
0 Comment(s)