Lecture overview -- Keyboard shortcut: 'u'  Previous page: Structs in C# -- Keyboard shortcut: 'p'  Next page: Structs versus classes -- 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 11 : 29
Object-oriented Programming in C#
Reference types, Value types, and Patterns
Structs and Initialization

Structs have constructors in the same way as classes. There are, however, a few special rules of constructors in structs. These special rules are described on this page.

The means for initialization of struct values are slightly different from the means for initialization of class instances (objects)

/user/normark/oop-csharp-1/sources/c-sharp/struct-experiments/structs1.csFields in structs cannot have initializers.


/user/normark/oop-csharp-1/sources/c-sharp/struct-experiments/structs2.csAn explicit parameterless constructor is not allowed.


 

Initializers cannot be used in Structs

The parameterless default constructor cannot be redefined.