让我们看一个Equality运算符的例子
using System; public class Demo { public static void Main() { string str1 = "Amit"; string str2 = " "; Console.WriteLine("Is string1 null or empty? = "+string.IsNullOrEmpty(str1)); Console.WriteLine("Is string2 null or empty? = "+string.IsNullOrEmpty(str2)); Console.WriteLine("Is string1 equal to str2? = "+str1 == str2); } }输出结果
Is string1 null or empty? = False Is string2 null or empty? = False False输出结果
Is string1 null or empty? = False Is string2 null or empty? = False Is str1 not equal to str2? = False