1.

Which of these methods is used to compare two strings such that after comparison output returns different integer values as (0 for false, 1 for true)?(a) Equals ()(b) == operator(c) Compare()(d) None of the mentionedI have been asked this question in an online interview.Asked question is from Comparison of Strings topic in section Arrays and Strings of C#

Answer»

The correct option is (c) COMPARE()

Easiest explanation - The comparison is case SENSITIVE in nature and hence different integer values are RETURNED for different conditions as under:

1. zero integer (0), if string s1 equal to string s2.

2. positive integer(+1), if string s1 greater than s2.

3. Negative integer(-1), if string s1 is LESS than s2.



Discussion

No Comment Found

Related InterviewSolutions