Imagine I have this class
public MyClass
{
public string FullName { get; set; }
}
I have an api client that returns me this object like this with an extra property called Capitalized which capitalized all string properties for exemple.
public MyResult : MyClass
{
public MyClass Capitalized { get; set; }
}
Then I can access things like this :
MyResult result = /* call to api with my class */
Console.WriteLine(result.FullName);
Console.WriteLine(result.Capitalized.FullName);
Is there a way to define a generic MyResult like this, because T can be MyClass, YourClass and the response will always be like :
public MyResult<T> : T
{
public T Capitalized { get; set; }
}
EDIT : thanks to @Maruf reply Eric Lippert explains it here why it is impossible : https://stackoverflow.com/a/5890813/1026105