C# Programming - Strings - Discussion

Discussion :: Strings - General Questions (Q.No.14)

14. 

If s1 and s2 are references to two strings then which of the following are the correct ways to find whether the contents of the two strings are equal?

  1. if(s1 = s2)
  2. if(s1 == s2)
  3. int c;
    c = s1.CompareTo(s2);
  4. if( strcmp(s1, s2) )
  5. if (s1 is s2)

[A]. 1, 2
[B]. 2, 3
[C]. 4, 5
[D]. 3, 5

Answer: Option B

Explanation:

No answer description available for this question.

Harshit Gupta said: (Feb 15, 2018)  
But == operator is for reference equality. It is not there for content equality. So how?

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.