我想为复杂类型定义自己的别名.我很好奇为什么编译器不能识别已导入的类型.例如:
作品:
using System;
using System.Collections.Generic;
using myCollection = System.Collections.Generic.List
<System.Collections.Generic.Dictionary<string, string>>;
Run Code Online (Sandbox Code Playgroud)
错误:
using System;
using System.Collections.Generic;
using myCollection = List<Dictionary<string, string>>;
Run Code Online (Sandbox Code Playgroud)
试试这个:
using System;
using System.Collections.Generic;
namespace ConsoleApplication1
{
using myCollection = List<Dictionary<string, string>>;
}
Run Code Online (Sandbox Code Playgroud)
using指令不能引用在同一范围内导入的类型.上面的示例有效,因为最后一个using指令仅引用在外部作用域中导入的类型.
| 归档时间: |
|
| 查看次数: |
318 次 |
| 最近记录: |