c#结构体&枚举


结构体(struct)是由一系列具有相同类型或不同类型的数据构成的数据集合,叫做结构。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    class Program
    {
      结构
struct human 在class Program中添加 { public int age; public bool isman; public double height; public double weight; public string name; }       枚举 enum week 相当于单选的下拉菜单 { 星期一, 星期二, 星期三, 星期四, 星期五, 星期六, 星期日 } static void Main(string[] args) { human ck; 定义一个人名 ck.age = 30; ck.isman = true; ck.height = 180.2; ck.weight = 80.1; ck.name = "崔凯"; Console.WriteLine(ck.GetType()); Console.ForegroundColor = ConsoleColor.Red; 将输出的结构变成红颜色 Console.WriteLine(week.星期一); Console.ReadLine(); } } }
原文地址:https://www.cnblogs.com/skyhorseyk/p/7000059.html