mercredi 5 février 2020

Determine if a class member's type was defined as a generic parameter

Given a generic class:

public class Foo<T>
{
    public T Foo { get; set; }
    public string Bar { get; set; }
}

Declared as:

var someVar = new Foo<string>();

Is there any way to tell if the type of Foo is defined as a generic T and not string?

I know you can check if the type of Foo is a string, but I want to determine if a member is defined by a generic parameter.





Aucun commentaire:

Enregistrer un commentaire