Advertisement
Tishy

C# Constructor / Destructor(Finalizer)

Sep 7th, 2019
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.52 KB | None | 0 0
  1.     public class SomeClass : AnotherClass //inheritance
  2.     {
  3.         SomeClass() //Constructor
  4.         {
  5.             //Do something when an object of this class is created
  6.         }
  7.  
  8.         ~SomeClass() //Destructor or Finalizer
  9.         {
  10.             //Do something when an object of this class is getting 'destroyed'
  11.         }
  12.  
  13.         SomeClass(string name) : base(age, health) //inherit constructor from inherited class
  14.         {
  15.             //Do something when an object of this class is created
  16.         }
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement