我有以下C ++ / CLI代码:
String^ str = gcnew String("", 0, 10);
bool isEmpty = String::IsNullOrEmpty(str);
为什么String::IsNullOrEmpty()
返回false?
答案 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,因此不为空。