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
You can also use this to do casting with conversions if needed:
public static IEnumerable CastAll(this IEnumerable items)
{
var p = Expression.Parameter(typeof(TItem), "i");
var c = Expression.Convert(p, typeof(TDest));
var ex = Expression.Lambda>(c, p).Compile();
foreach (var item in items)
{
yield return ex(item);
}
}
From http://adventuresdotnet.blogspot.com/2010/06/better-more-type-safe-alternative-to.html