On the client, I have an array of ints on which I call a ToString method; I’m then sending that string to the server via ajax.
On the server, I’m writing this:
var TestList = (from string s in TheString.Split(',')
select Convert.ToInt64(s)).ToList<long>();
Is this going to crash if the incoming string actually contains unexpected values?
Thanks.
If the string contains unexpected values it could throw a
FormatExceptionor anOverflowExceptionas mentioned in the documentation forConvert.ToInt64(string).To avoid the exception you could use
bool long.TryParse(string, out long).