I’m having a weird problem, trying to take a string from a string array
and convert it to an integer.
Take a look at this code snippet:
string date = "21/07/2010 13:50";
var date1 = date.Split(' ')[0];
string[] dateArray = date1.Split('/');
string s = "21";
string t1 = dateArray[0];
bool e = string.Compare(s, t1) == 0; //TRUE
int good = Convert.ToInt32(s); //WORKING!
int bad = Convert.ToInt32(t1); //Format exception - Input string was not in a correct format.
Can someone please explain why the conversion with s works, while with t1 fails?
Your string is full of hidden characters, causing it to break. There’s four
U+200Eand oneU+200FHere’s a clean string to try on: