为什么String :: IsNullOrEmpty()在C ++ / CLI中返回false?

时间:2014-12-19 19:13:25

标签: .net string c++-cli

我有以下C ++ / CLI代码:

String^ str = gcnew String("", 0, 10);
bool isEmpty = String::IsNullOrEmpty(str);

为什么String::IsNullOrEmpty()返回false?

1 个答案:

答案 0 :(得分:2)

您正在使用this constructor(错误地):

public String(
    char* value,
    int startIndex,
    int length 
)

其中

length 
    Type: System.Int32 
    The number of characters within value to use.

因此,字符串的长度为10,因此不为空。