C# FAQ

How well do you know C#?

Answer to Test 1
The answer is 1000.

How come?
In the following statement, the struct c is cast to a reference:
       ((Employee)c).GiveRaise(50);
This involves boxing. A copy of c is made, and the GiveRaise method is called on that copy, not on the original object.

Removing the cast will produce the expected answer.

Read more
More information is available under structs and boxing.



[Back to Index]













1