• 结构类型


    实现效果:
      

    实现代码:

            static void Main(string[] args)
            {
                Console.WriteLine("***A First Look at Structures***
    ");
                //创建初始Point
                Point myPoint = new Point();   //使用默认构造函数将所有字段设置为默认值
                myPoint.x = 199;
                myPoint.y = 99;
                myPoint.Display();
                //调整X和Y
                myPoint.Increment();
                myPoint.Display();
                Console.ReadKey();
            }
            struct Point
            {
                //结构的字段
                public int x;
                public int y;
                //将XY坐标增加1
                public void Increment()
                {
                    x++; y++;
                }
                //将XY坐标减去1
                public void Decrement()
                {
                    x--; y--;
                }
                //显示当前坐标
                public void Display()
                {
                    Console.WriteLine("X={0},Y={1}",x,y);
                }
            }
    

      

  • 相关阅读:
    hdu 3496
    poj 2374
    zoj 3399
    poj 1321
    sgu 365
    hdu 3555
    poj 3345
    poj 2355
    Android重命名文件
    在workflow中传值的sample
  • 原文地址:https://www.cnblogs.com/feiyucha/p/10349757.html
Copyright © 2020-2023  润新知