Using C#, I need to convert a substring to an int even if the value of the substring is null.
My code reads lines of a text file and then assigns certain parts of the text to strings.
int _CUSTBAL = Convert.ToInt32(line.Substring(5, 2));
Example Text:
12345 10 etc
12346 20 etc
12347 etc
The issue I'm having is that if the line contains a blank space it throws an exception. I need it to return zero if the substring contain a blank. For example. If the text is formatted blank9 then I need to return 09. I've tried using nullable types but that doesn't do the trick. Thanks