using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp12
{
interface IPoint
{
int x { get; set; }//定义成员变量x,它含有读写抽象访问
int y { get; set; }
}
class Point :IPoint
{
private int px;
private int py;
public Point(int x,int y)//构造函数
{
px = x;
py = y;
}
public int x//接口属性实现
{
get { Console.WriteLine("\n调用接口读取数据px"); return px; }
set { Console.WriteLine("\n调用接口写入数据px"); px = value; }
}
public int y//接口属性实现
{
get { Console.WriteLine("调用接口读取数据py"); return py; }
set { Console.WriteLine("\n调用接口写入数据px"); py = value; }
}
}
class Program
{
static void Main(string[] args)
{
Point p = new Point(4, 30);
Console.Write("新创建的point点的坐标是:");
p.x = 666;
Console.WriteLine("x={0},y={1}",p.x,p.y);
Console.ReadKey();
}
}
}