I have this class:
class Foo { public string Name { get; set; } }
And this class
class Foo<T> : Foo { public T Data { get; set; } }
Here is what I want to do:
public Foo<T> GetSome() { Foo foo = GetFoo(); Foo<T> foot = (Foo<T>)foo; foot.Data = GetData<T>(); return foot; }
What is the easiest way to convert Foo to Foo <T>? I cannot directly use InvalidCastException), and I do not want to copy each property manually (in my actual use case, there is more than one property) if I do not need it. Is custom type conversion capable?
source share