How i can get full right name of generic type?
For example:
This code
typeof(List<string>).Name
return
List`1
instead of
List<string>
How to get a right name?
typeof(List<string>).ToString()
returns System.Collections.Generic.List`1[System.String] but i want to get initial name:
List<string>
Is it real?
Use the FullName property.
That will give you the namespace + class + type parameters.
What you are asking for is a C# specific syntax. As far as .NET is concerned, this is proper:
So to get what you want, you’d have to write a function to build it the way you want it. Perhaps like so:
For these types (with true as 2nd param):
It returns:
In general though, I’d bet you probably don’t need to have the C# representation of your code and perhaps if you do, some format better than the C# syntax would be more appropriate.