mardi 30 octobre 2018

How do I print the name of generic classes in c#?

Is there a simple way to obtain the name of a class in c# including template parameters?

I.E

Print( new List<int>{ 100, 1001}); 

Produce one of the following outputs:

List<int>
List<Int32>
System.Collections.Generics.List<System.Int32>

one of the first 2 is preferrable, but Type.FullName is not a viable option. It is ways too verbose.

Too verbose result that is unwanted.

System.Collections.Generic.List`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=235hosehoue5h]]

Note I'm asking just for a shortcut if it exists. I'm no asking for a full implementation of such feature.





Aucun commentaire:

Enregistrer un commentaire