Membership Service in ASP.Net 2.0

Membership Service in ASP.Net 2.0
Published on http://asp.net on 10/16/2008

Monday, April 15, 2013

== vs .Equals()

In .Net you could use "==" or .Equals()

== will return true if the reference types are pointing to object in Memory.

.Equals will perform case sensitive and character by character equality check.


            StringBuilder a = new StringBuilder("anubhav");
            StringBuilder b = new StringBuilder("anubhav");

            if (a == b)
                Console.WriteLine("a==b is true");
            else
                Console.WriteLine("a==b is false");

            if(a.Equals(b))
                Console.WriteLine("a.equals(b) is true");
            else
                Console.WriteLine("a.equals(b) is false");


Output :
a==b is false
a.equals(b) is true

No comments: