using System;
class Number
{
int number;
public int Anumber
{
get
{
return number;
}
set
{
number=value;
}
}
}
class PropertyTest
{
static void Main()
{
Number n = new Number();
n.Anumber=100;
int m=n.Anumber;
Console.WriteLine("m = "+m);
}
}
-------------------------- or ------------------------------------
using System;
class Number
{
public int Anumber{ get; set; }
}
class PropertyTest
{
static void Main()
{
Number n = new Number();
n.Anumber=100;
int m=n.Anumber;
Console.WriteLine("m = "+m);
}
}
Output:-
No comments:
Post a Comment