0

这是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;
 }

错误在线:

while (!String.IsNullOrEmpty(s))

在弦上

错误/秒都与字符串有关:

这是一个警告:

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

我该如何修复它们?

4

1 回答 1

4

由于IsNullOrEmpty是一个静态函数,您可能必须使用::运算符调用它:

while (!String::IsNullOrEmpty(s))
于 2013-05-04T10:13:54.647 回答