Get-Set property in C#
using System;
using System.Collections.Generic;
using System.Text;
namespace Get_Set_Test
{
class Program
{
static void Main(string[] args)
{
//CREATE OBJECT
GetSet_Test obj = new GetSet_Test();
//SET VALUE OF THAT CLASS
obj.Val = 5;
//GET VALUE OF THAT CLASS
Console.WriteLine(obj.Val);
Console.ReadLine();
}
public void TypeTest(Control
obj)
{
}
}
class GetSet_Test
{
int val;
///
/// Set or Get value of variable
///
public int Val
{
//SET VALUE TO VARIABLE
set
{
val = value; ;
}
//GET VALUE OF THAT VARIABLE
get
{
return val;
}
}
}
}
1 comments