C++ cli 错误!String.IsNullOrEmpty(s))

C++ cli 错误!String.IsNullOrEmpty(s)),c++-cli,C++ Cli,这是c语言的代码++ List<String^> ^GetCodecs() { List<String^> ^l = gcnew List<String^>; String ^s = gcnew String(Encoder_GetFirstCodecName()); while (!String.IsNullOrEmpty(s)) { l->Add(s); s = gcnew Strin

这是c语言的代码++

List<String^> ^GetCodecs()
{
    List<String^> ^l = gcnew List<String^>;

    String ^s = gcnew String(Encoder_GetFirstCodecName());
    while (!String.IsNullOrEmpty(s))
    {
        l->Add(s);
        s = gcnew String(Encoder_GetNextCodecName());
    }

    return l;
 }
悬而未决

错误都与字符串有关:

这是一个警告:

Warning 1   warning C4832: token '.' is illegal after UDT 'System::String'
错误:

Error   2   error C2275: 'System::String' : illegal use of this type as an expression
Error   3   error C2228: left of '.IsNullOrEmpty' must have class/struct/union
Error   4   error C1903: unable to recover from previous error(s); stopping compilation
Error   5   IntelliSense: type name is not allowed

如何修复它们?

由于
IsNullOrEmpty
是一个静态函数,您可能需要使用
操作符调用它:

while (!String::IsNullOrEmpty(s))

由于
IsNullOrEmpty
是一个静态函数,因此可能需要使用
运算符调用它:

while (!String::IsNullOrEmpty(s))