Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following C# code?
String a = “Csharp”;
String b = “CSHARP”;
int c;
c = a.CompareTo(b);
Console.WriteLine(c);

What will be the output of the following C# code?
String a = “Csharp”;
String b = “CSHARP”;
int c;
c = a.CompareTo(b);
Console.WriteLine(c);
a) 0
b) 1
c) -2
d) -1

Answer: d
Explanation: Negative integer -1 is returned as ‘a’ is less than ‘b’ by CompareTo() method.
Output :
-1

Join The Discussion