陈斌彬的技术博客

Stay foolish,stay hungry

Csharp 中的Equals()和==有什么区别?

操作符“==”在值类型情况下表示是否值相等.
equals 判断是否是同一个对象的引用.
string的==和equals都是比较值。 
static void Main(string[] args)
{

StringBuilder c = new StringBuilder("AAA");
StringBuilder d = new StringBuilder("AAA");
Console.WriteLine(c==d); //false
Console.WriteLine(c.Equals(d));//true

}

img