【发布时间】:2022-10-13 04:07:47
【问题描述】:
我正在使用 c++ cli。
每次为 IList 编写“System::Collections::Generic::IList”很困难,使代码冗长且难以阅读。
这里讨论了enter link description here
using IList = System::Collections::Generic::IList; // Didn't work.
typedef System::Collections::Generic::IList Ilist; // Didn't work also.
我怎样才能为它制作别名?
【问题讨论】:
-
typedef 工作正常。但这是泛型类型,您必须确定类型参数才能命名具体类型。所以,比如说,
typedef System::Collections::Generic::IList<int> mylist;。您可以编写一个模板来提供类型参数,但它们在元数据中表现不佳。