What is the difference between a.Equals(b) and a == b?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #3334
    Ankur
    Member

    What is the difference between a.Equals(b) and a == b?

    #3336
    Pavan
    Member

    Hello Ankur,

    .Equals and == both used to compare.But internal working of both little bit different.
    .Equals work fine reference type and == work fine value type.
    Like if we string builder.The StringBuilder is reference type.

    StringBuilder a = new StringBuilder(“Pavan”);
    StringBuilder b= new StringBuilder(“Pavan”);

    a.Equals(b)–> return true
    a==b —> return false

    please let me know if you have any doubt.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.