Fun with Equality

Brad Abrams Posted a small Equality Quiz
Its just 10 min but it was fun. Here are my answers (Try yoursellf first)
public static void Question1()
{
int x = 10;
long y = 10;
Console.WriteLine(x==y && !x.Equals(y));
}
public static void Question2()
{
object x = 10;
object y = 10;
Console.WriteLine(x!=y && x.Equals(y));
}
public static void Question3()
{
object x = new object();
int y = 10;
Console.WriteLine(x==y);
}
public static void Question4()
{
int x = 10;
int y = 10;
Console.WriteLine(x == y && (object)x!=(object)y);
}

Advertisements

One thought on “Fun with Equality

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s