mardi 19 mai 2020

Type.IsPrimitive working for generic types?

If I write the following generic method:

static bool HelloWorld<TSource>(TSource input)
{
    return typeof(TSource).IsPrimitive;
}

and I pass an int to it, it successfully recognizes it as a primitive. If I pass a string for example, it will not - which means it works.

The documentation states that it shouldn't work though, or am I miss-reading something?

If the current Type represents a generic type, or a type parameter in the definition of a generic type or generic method, this property always returns false.





Aucun commentaire:

Enregistrer un commentaire