Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C# Programming Question

Name: Anonymous 2010-10-21 14:24

object a = 10;
object b = 10;
object c = "10";
object d = "10";

Console.WriteLine(a == b); // false
Console.WriteLine(c == d); // true

why does the "Console.WriteLine(a == b)" outputs "false"?

Name: Anonymous 2010-10-21 16:20

>>1
Console.WriteLine(a == b); // false
Console.WriteLine(a.Equals(b)); // true                                       
/* For arguments of value type, the operator == returns true if its            
   operands have the same value, false otherwise. For the string type,         
   it returns true if the strings' character sequences match. For other        
   reference types (types derived from System.Object), however, a == b         
   returns true only if a and b reference the same object. */

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List