Classes C# with Example



Classes C# with Example

Skeleton of declaring class is: 
<>:Required 
[]:Optional 
[private/public/protected/internal] class  [:[Inherited class][,][[Interface 
Name 1],[Interface Name 2],...] 
{ 
//Your  code 
} 
Don't worry if you can't understand whole syntax,We'll be get familiar with all part of that.for first example consider 
following class: 
class MyClass 
{ 
int i = 100; 
public void getMyValue() 
{ 
Console.WriteLine(this.i);//Will print number 100 in output 
} 
} 
in this class we create variable i with int type and with default private Access Modifiers and getMyValue() method 
with public access modifiers. 
 

0 Comment's

Comment Form

Submit Comment