Classes and Objects in C#



A Class is like an object constructor or a "blueprint" for creating objects

create a class, use the class keyword
  1. class ExampleOne  
  2. {  
  3.   string col= "green";  
  4. }  
 create an object called "obj" and use it to print the value of col
 
  1. class ExampleTwo   
  2. {  
  3.   string col = "green";  
  4.   
  5.   static void Main(string[] args)  
  6.   {  
  7.     ExampleTwo obj = new ExampleTwo();  
  8.     Console.WriteLine(myObj.col);  
  9.   }  
  10. }  

0 Comment's

Comment Form

Submit Comment