Object Oriented Programming

Class Declaration and Structure in C#

Classes are a blueprint for creating individual objects that contain the general characteristics of a defined object type.


Syntax
modifier class myClass { 
   //field, constructor, and 
   //method declarations 
}

Notes

Class body contains constructors for initializing new objects, declarations for the fields that provide the state of the class and its objects, and methods to implement the behaviour of the class and its objects.


Example
public class Rectangle { 
   float length; 
   float width; 
}

< Try Catch Block   |   Access Modifiers >

© 2019 SyntaxDB. All Rights Reserved.