3条回答 默认 最新
- CSDN专家-showbo 2021-06-18 07:44关注
using System; namespace ConsoleApp1 { class MyPoint { private int x; private int y; public int PX { get { return x; } set { x = value; } } public int PY { get { return y; } set { y = value; } } public MyPoint() { this.x = this.y = 0; } public MyPoint(int x, int y) { this.x = x; this.y = y; } ~MyPoint() { Console.WriteLine("MyPoint实例资源回收~~"); } public void ShowPoint() { Console.WriteLine("x:{0}\ty:{1}", x, y); } public float Disp() { return (float)Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2)); } } class Program { static void Main(string[] args) { var p0 = new MyPoint(); var p1 = new MyPoint(4, 5); Console.WriteLine(p1.Disp()); } } }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报