I have an ArrayList that comes from a json deserializer. This array should only contain numbers but as always, bad things can happen and I’m looking to avoid having to handle an exception. This is what I have:
var TheListOfLongs = (from object s in TheArrayList
select Convert.ToInt64(s)).ToList<long>();
This works fine as long as TheArrayList only contains numbers. How can I change the Convert.ToInt64 statement to a TryParse?
Thanks.
or good old foreach, which is probably the best choice.