Lecture overview -- Keyboard shortcut: 'u'  Previous page: Boxing and Unboxing -- Keyboard shortcut: 'p'  Next page: Organization of C# Programs [Section] -- 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 16 : 29
Object-oriented Programming in C#
Reference types, Value types, and Patterns
Nullable types

Nullable types fuse an extra null value into existing value types.

A variable of reference type can be null

A variable of value type cannot be null

A variable of nullable value type can be null

/user/normark/oop-csharp-1/sources/c-sharp/int-sequence/intseq-naive.csAn integer sequence with Min and Max operations - a naive attempt.


/user/normark/oop-csharp-1/sources/c-sharp/int-sequence/intseq.csAn integer sequence with Min and Max operations - with int?.


/user/normark/oop-csharp-1/sources/c-sharp/int-sequence/app.csA client of IntSequence.


/user/normark/oop-csharp-1/sources/c-sharp/int-sequence/outputProgram output.


  • Nullable types in C#:

    • Many operators are lifted such that they also are applicable on nullable types

    • An implicit conversion can take place from t to t?

    • An explicit conversion (a cast) is needed from t? to t