C#判断字符串为空有哪几种方法

2025-01-31 03:14:18
推荐回答(1个)
回答1:

三种常用的字符串判空串方法:
Length法:bool isEmpty = (str.Length == 0);
Empty法:bool isEmpty = (str == String.Empty);
General法:bool isEmpty = (str == "");