|
|
Passing references as value parameters | Be warned! This is not a discussion of C# reference parameters.
It is a discussion of how to pass references via value parameters. |
Care must be taken if we pass references as value parameters |
This class introduces the DayDifference method, which accepts a formal Date parameter. |
We pass a reference to a Date object as an actual parameter. |
A class with a Main method which - indirectly - calls the method of interest. |
The output that appears if you run the program shown above. |
|
In case a reference is passed as an argument to a value parameter, the referenced object can be modified through the formal parameter | This is the main point to remember from this page! |
Read more about references passed by value in the text book version of this material. |