Consider the following :
static void Main(string[] args)
{
List<int> myList = Enumerable.Range(0, 100).ToList();
try
{
List<long> myListLong = myList.Cast<long>().ToList();
}
catch (InvalidCastException e)
{
Console.WriteLine("Error");
}
Console.ReadLine();
}
Why is my list of integer generating an InvalidCastException here ?
Is it because both types are structure ?