方法

来源:互联网 发布:淘宝随意退货 编辑:程序博客网 时间:2024/04/28 12:03

方法是一种用于实现可以由对象或类执行的计算或操作的成员声明方法:[方法修饰符]返回类型 方法名([参数]){}using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace 方法实例{    class Program    {        static void Main(string[]args)        {            pointA = newpoint();//建立Point 实例            A.Assign();//调用Assign            Console.Write("A点在:");            Console.Write("(" + A.x + ","+ A.y + ")");            Console.ReadKey();        }    }    class point    {        public int x, y;        public void Assign()        {            Console.WriteLine("输入你要输入的point值");            x = int.Parse(Console.ReadLine());            y = int.Parse(Console.ReadLine());                   }     }} 


原创粉丝点击