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?
- x == x
- (object) x == (object) x
- (System.Object) x == (System.Object) x
- (int) (object) x == (int) (object) x
- (float) x == (float) x
- (int) x == (int) x
- (int) x == (float) x
- (float) (int) x == (int) (float) x
- (System.Int32) x == (System.Int32) x
- x.ToString() == x.ToString()
- (object) x.ToString() == (object) x.ToString()
The Answers.