Moh*_*kar 1 .net extension-methods c++-cli visual-c++
我在C++ CLI中的代码:
[System::Runtime::CompilerServices::ExtensionAttribute]
public ref class MyExtensions abstract sealed {
public:
[System::Runtime::CompilerServices::ExtensionAttribute]
static System::String^ SetC() {
return gcnew System::String("{") + gcnew System::String("}") ;
}
}
Run Code Online (Sandbox Code Playgroud)
但是后面的行抛出一个错误,即String没有成员SetC.
System::String("").SetC();
Run Code Online (Sandbox Code Playgroud)
我也试过使用以下代码:
gcnew System::String("")->SetC();
Run Code Online (Sandbox Code Playgroud)
什么错过了吗?