I am working on code generation and ran into a snag with generics. Here is a "simplified" version of what is causing me issues.
Dictionary<string, DateTime> dictionary = new Dictionary<string, DateTime>();
string text = dictionary.GetType().FullName;
With the above code snippet the value of text
is as follows:
System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.DateTime, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
(Line breaks added for better readability.)
Is there a way to get the type name (type
) in a different format without parsing the above string? I desire the following result for text
:
System.Collections.Generic.Dictionary<System.String, System.DateTime>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…