Here is some most common programming errors and tips for c# developers.
Use Convert.ToString() instead of .ToString()
Convert.ToString function handles null values whereas .ToString() cannot handle null values and throw error "Object Reference not set to an instance of an object."
Use Convert.ToString() instead of .ToString()
Convert.ToString function handles null values whereas .ToString() cannot handle null values and throw error "Object Reference not set to an instance of an object."
Use StringSplitOptions.RemoveEmptyEntries while splitting the string
When we split some string and perform some operations on each portion of string, using StringSplitOptions.RemoveEmptyEntries is a good practice this will remove empty strings from the returned Array, and remaining operations does not give an error.
Use TryParse instead of Convert function for converting Int, double, boolean etc.
If the object is null or not valid value for conversion this functions throw an error while TryParse returns 0 in case of null or wrong input.