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

References are important in C#. A reference is similar to a point in C, but references are much easier to work with. References can be passed around (via parameters). Objects are always accessed via references, but in contrast to C, the following of a references happens implicitly, and automatically.

References in C# can be understood as a very restricted notion of pointers, as known from C programming

  • Pointers

    • In normal C# programs: Pointers are not used

      • All the complexity of pointers, pointer arithmetic, dereferencing, and the address operator is not found in normal C# programs

    • In specially marked unsafe sections: Pointers can be used almost as in C.

      • Do not use them in your C# programs!

  • References

    • Objects (instance of classes) are always accessed via references in C#

    • References are automatically dereferenced in C#

    • There are no particular operators in C# that are related to references

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


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


There is no particular complexity in normal C# programs due to use of references