如果我有以下代码:
MyType<int> anInstance = new MyType<int>();
Type type = anInstance.GetType();
Run Code Online (Sandbox Code Playgroud)
通过查看类型变量,如何找出实例化的"anInstance"类型参数?可能吗 ?
我最近需要为任意类型构建C#特定名称(必须始终包含global :: specifier),并且遇到以下问题:
// 1 - value: System.String[,,,][,,][,]
string unexpectedFullName = typeof( string[,][,,][,,,] ).FullName;
// 2 - value: System.String[,][,,][,,,]
string expectedFullName = Type.GetType( "System.String[,][,,][,,,]" ).FullName;
Run Code Online (Sandbox Code Playgroud)
我期待两种情况下返回的值都相同.但是,由于某种原因,数组相关的部分值似乎是相反的(案例1).这是逆转的预期行为吗?