<$BlogRSDURL$>
Ankh Morpork's Finest Coder
Sunday, March 06, 2005

Questions on C#
Mike Stall's C# pop-quiz about equality. Given a local variable x declared of type ‘int’, what do the following C# expressions evaluate to?

  1. x == x
  2. (object) x == (object) x
  3. (System.Object) x == (System.Object) x
  4. (int) (object) x == (int) (object) x
  5. (float) x == (float) x
  6. (int) x == (int) x
  7. (int) x == (float) x
  8. (float) (int) x == (int) (float) x
  9. (System.Int32) x == (System.Int32) x
  10. x.ToString() == x.ToString()
  11. (object) x.ToString() == (object) x.ToString()

The Answers.


0 Comments:

Post a Comment