How can I get the correct text definition of a generic type using reflection?

前端 未结 6 1344
萌比男神i
萌比男神i 2020-12-01 14:17

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

        
6条回答
  •  孤城傲影
    2020-12-01 14:34

    string text = dictionary.ToString();
    

    provides almost what you are asking for:

    System.Collections.Generic.Dictionary`2[System.String,System.DateTime]
    

提交回复
热议问题