Lecture overview -- Keyboard shortcut: 'u'  Previous page: Passing references as value parameters -- Keyboard shortcut: 'p'  Next page: Reference Parameters -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 23 : 29
Object-oriented Programming in C#
Data Access, Properties, and Methods
Passing structs as value parameters

On this page we repeat the example from the previous page - but now on a struct instead of a class.

There are no surprises when we pass struct values as value parameters

/user/normark/oop-csharp-1/sources/c-sharp/method-parameters/by-value/struct/date.csThe struct Date and the method DayDifference with a value parameter. This program is explained

The exact similar setup as on the previous page.

/user/normark/oop-csharp-1/sources/c-sharp/method-parameters/by-value/struct/person.csThe class Person which calls DayDifference on dateOfBirth. This program is explained


/user/normark/oop-csharp-1/sources/c-sharp/method-parameters/by-value/struct/Client.csA client of Person and Date which reveal the consequences. This program is explained


/user/normark/oop-csharp-1/sources/c-sharp/method-parameters/by-value/struct/outputClient program output.


Go to exercisePassing struct values as ref parameters
There is a good fit between use of value types and call-by-value parameter passing

Read more about struct values passed by value in the text book version of this material.