C#结构体

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/*
 * 结构是自定义的数据类型,与类类似,包含数据成员和函数成员
 * 1、结构是值类型
 * 2、结构是隐式密封的不可以派生
 * 3、结构中字段初始化是不允许的
 */
namespace ExStruct
{
    struct Simple
    {
        public int x;
        public int y;
        public Simple(int _x, int _y)
        {
            x = _x;
            y = _y;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Simple s1 = new Simple();
            s1.x = 10; s1.y = 90;
            Console.WriteLine("x:{0},y:{1}", s1.x, s1.y);
            Simple s2 = new Simple(9,9);
            Console.WriteLine("x:{0},y:{1}", s2.x, s2.y);
            Console.ReadKey();
        }
    }
}
原文地址:https://www.cnblogs.com/sulong/p/4797246.html