int i = 1;
int j = 1;
System.Console.WriteLine(i == j);
System.Console.WriteLine(i.ToString() == j.ToString());
System.Console.WriteLine((object)i == (object)j);
Give the sample code above, what is the output to the console?
Answers were Sorted based on User's Feedback
Answer / sahdev singh
True - First time we are comparing only values.
True - Second time also we are comparing only values.
False - We are comparing reference of two objects.
Is This Answer Correct ? | 9 Yes | 3 No |
Answer / sasi
static void Main(string[] args)
{
int i = 1, j = 1;
Console.WriteLine(i + j);
Console.WriteLine("\n" + i.ToString() + j.ToString());
Console.WriteLine("\n"+((object)i==(object)j));
Console.ReadLine();
}
output:-
2
11
false
Is This Answer Correct ? | 4 Yes | 1 No |
Answer / manoj yadav
1.TRUE... here we only comparing two value. if it is true.
then it wil execute (1==1).
2. TRUE.. here first we convert the int value in to string.
as bothe value are same so converted value wl also same
string so
3. WRONG..here we first give a reference to object. as
bothe objects reference cant be same so FALSE
Is This Answer Correct ? | 3 Yes | 0 No |
Is there an equivalent of exit() for quitting a c# .net application?
How big is a float?
What is the difference between c and c# programming?
What r collections c sharp?
What is the main purpose of delegates in c#?
Describe two uses of the “using” statement during the operation of c#?
What namespaces are necessary to create a localized application?
What is .cshtml file?
What is the use of console readkey ()?
What is the difference between string keyword and system.string class?
what is a static constructor?
what are delegates? How you used then in your project?
10 Answers Hawk Eye, IndiaTimes, Kanbay,