Coding Lab - TechOnTechnology

Program in C# to illustrate the use of different properties.

using System;
class Point
{
int x,y;
public Point()
{
}
public Point(int x,int y) {
this.x=x;
this.y=y;
}
public int X
{
set {
this.x=value;
}
get {
return this.x;
}
}
public int Y
{
set {
this.y=value;
}
get {
return this.y;
}
}
}
class PrintApp {
public static void Main(String[] args)
{
Point p=new Point();
p.X=2;
p.Y=5;
Console.WriteLine(“x = “+p.X+” y = “+p.Y);
p.X++;
p.Y+=2;
Console.WriteLine(“After x++ and y+2″);
Console.WriteLine(“x = “+p.X+” y = “+p.Y);
}
}


Name

Email *

Message *