Lecture overview -- Keyboard shortcut: 'u'  Previous page: Pointers and references -- Keyboard shortcut: 'p'  Next page: Operators -- 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 12 : 43
Object-oriented Programming in C#
Introduction to C#
Structs

Structs in C and C# are similar to each other. But structs in C# are extended in several ways compared to C.

The concept of structs has been much extended in C#

  • Similarities

    • Structs in C# can be used almost in the same way as structs in C

    • Structs are value types in both C and C#

  • Differences

    • Structs in C# are almost as powerful as classes

      • Structs in C# can have operations (methods) in the same way as classes

      • Structs in C# cannot inherit from other structs or classes

/user/normark/oop-csharp-1/sources/c-sharp/introductory-examples/structs/struct-demo-1.csDemonstrations of structs in C#. This program is explained


/user/normark/oop-csharp-1/sources/c-sharp/introductory-examples/structs/outputOutput from the struct demo program.


/user/normark/oop-csharp-1/sources/c-sharp/introductory-examples/structs/struct-demo.csAn extended demonstration of structs in C#. This program is explained