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

Home Forums General Programming What is the difference between a.Equals(b) and a == b?

This topic contains 0 replies, has 2 voices, and was last updated by  Pavan 6 years, 8 months ago.

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

    Ankur
    Moderator

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

    #3336

    Pavan
    Moderator

    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.