在C#12(.NET 8)之后,所有类型都可以别名:
using A = int;
using B = string;
using C = Dictionary<int, string>;
但是,它不能写为
using A = int;
using B = string;
using C = Dictionary<A, B>;
这是一个错误,还是仅仅是一个功能? 有什么解决办法吗?
在C#12(.NET 8)之后,所有类型都可以别名:
using A = int;
using B = string;
using C = Dictionary<int, string>;
但是,它不能写为
using A = int;
using B = string;
using C = Dictionary<A, B>;
这是一个错误,还是仅仅是一个功能? 有什么解决办法吗?
这documentation of the compiler Error CS0246人解释说
一个
using
别名指令不使用 解析类型的源代码文件.
因此,在声明新别名时,同一源代码文件中定义的其他别名不可见.