今天偶然发现using关键字的另外一个用处,原来它还可以给类或命名空间指定别名,真是有趣啊,如果命名空间或类名很长,而且还要在程序中反复使用多次,但还不希望该命名空间的名称包含在using指令中(例如避免命名冲突),那它的作用就发挥到了,语法如下:
      using generic =  System.Collections.Generic;
      generic::IList<string> list = new generic::List<string>();
注意哦,使用方式,别名后面使用的是::

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-08
  • 2022-01-01
猜你喜欢
  • 2021-11-10
  • 2021-12-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-16
  • 2022-12-23
相关资源
相似解决方案