I'm trying to use LINQ
's cast
method to cast an array of strings
to an array of integers
but getting the error: Specified cast is not valid
, what am I doing wrong? Thanks!
string numbers = "1,2,3,4,5";
string[] nums = numbers.Split(',');
try
{
var ff = nums.Cast<int>().ToArray();
}
catch (Exception ex)
{
}