在C#中,使用string.IsNullOrEmpty方法可以判断一个字符串是否为null或者为空字符串。示例如下:
string myString = "Hello World"; if (string.IsNullOrEmpty(myString)) { Console.WriteLine("String is null or empty"); } else { Console.WriteLine("String is not null or empty"); }
在上面的示例中,如果myString为空或者为null,则会输出"String is null or empty";否则会输出"String is not null or empty"。