0
What is the encapsulation in OOPs concept in C# also define why are use the encapsulation?
What is the encapsulation in OOPs concept in C# also define why are use the encapsulation?
namespace namespace-name{
[access modifier] class class-name
{
// [access modifier] datatype variable-name
// [access modifier] datatype property-name{
Setter statement
Getter statement
}
// [access modifier] datatype function-name{
Function satement
}
}
}
namespace ENC.Com{
public class EncapsulationDemo
{
private int Size;
public int RowSize{
set{
Size=value;
}
get{
return Size;
}
}
public int GetSize(){
return Size;
}
}
}
using System;
public class Circle
{
private const float PI=3.14159f;
private int Size;
public int Radius{
set{
Size=value;
}
get{
return Size;
}
}
public float GetArea
{
get{
return GetTotalSize();
}
}
private float GetTotalSize(){
return Size * Size * PI;
}
}
public class Program
{
public static void Main()
{
Circle circle=new Circle();
circle.Radius=5;
Console.WriteLine('Area : '+circle.GetArea);
}
}
Output
Area : 78.53975