Encapsulation and Abstraction
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
namespace CSharp_Shell
{
/*
public class access
{
public string name; //This member can be accessed from outside bcz its public
private int age;//This member can only be used in this class bcz its private
protected string favouriteColor;
//
public int Age //Property for setting and getting age
{
get
{
return age;
}
set
{
age = value;
}
}
}
*/
public class Program : access //program is inherited from access
{
public static void Main()
{
/*
//public private
access person = new access();
person.name = "Adeel";
person.age = 12;
*/
//
/*
//Get set from private
access person = new access();
person.Age = 23;//set
Console.WriteLine(person.Age);//get
*/
//
/*
//Protected inheritance
Program person2 = new Program();
person2.favouriteColor = "Red";
Console.WriteLine(person2.favouriteColor);
*/
}
}
}
Comments
Post a Comment