如何在C++/CLI中将非空类型转换为可空?如何在C++/CLI中将非空类型转换为可空?
我知道该怎么做,在C#:
public Type GetNullableType(Type t)
{
return typeof(Nullable<>).MakeGenericType(t);
}
但我无法弄清楚,如何将其转换为C++/CLI。
我试过这个,但是当我编译代码时,我得到了内部编译器错误。
Type^ nullableType = Nullable<>.GetType();
return nullableType->MakeGenericType(t);
谢谢您的回答。可以写: 'Type^nullableType = Type :: GetType(“System.Nullable'1”);' – FeatureShock
你是对的。这也应该工作,我会更新我的答案。 – svick