Lecture overview -- Keyboard shortcut: 'u'  Previous page: Creating and Deleting Objects [Section] -- Keyboard shortcut: 'p'  Next page: Instantiation of 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 23 : 29
Object-oriented Programming in C#
Classes and Objects
Creating and Deleting Objects

On this page we outline possible ways to create and get rid of objects. Notice that all these possibilities are not necessarily supported in your favorite object-oriented programming language, such as C# or Java.

Possible approaches to creation and deletion of objects

  • Creating Objects

    • By instantiating classes

      • Implicitly: via variable declarations

      • Explicitly: on demand, by command

    • By copying existing object - cloning

  • Deleting Objects

    • Explicitly: on demand, by command

    • Implicitly: deleted when not used any longer - via use of garbage collection

Modern object-oriented languages support explicit object creation and implicit object deletion (by means of garbage collection)

Read more about creating and deleting objects in the text book version of this material.