using System class Test private int test public int Test get Console W

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
class Test
{
private int test;
public int Test
{
get
{
Console.WriteLine("Getting a property");
return test;
}
set
{
Console.WriteLine("Setting a property");
test = value;
}
}
}
class PlayGround
{
static void Main(string[] args)
{
Test t1 = new Test();
Test t2 = new Test();
t2.test = 321;
Console.WriteLine(t1.test);
Console.WriteLine(t2.test);
}
}