I\'ve created two classes, with one of them having an implicit cast between them:
public class Class1
{
public int Test1;
}
public class Class2
{
pu
Thanks for that I was about to use that exact case somewhere. You have saved me a pile of time. As a possible solution to your problem you could use ConvertAll<> instead, like so:
foreach (Class1 item in items.ConvertAll((i) => (Class1)i))
{
Console.WriteLine(item.Test1);
}
EDIT: or if you want to be more explicit that the cast is implicit then this works too:
foreach (Class1 item in items.ConvertAll(i => i))
{
Console.WriteLine(item.Test1);
}