枚举类型、结构体、数组

枚举类型的定义 赋值

namespace _526枚举类型
{
    enum GameState:byte //修改枚举的存储类型 默认为int
    {
        pause,  //每个都有默认的数值,从0开始
        failed,
        success,
        start
    }
    class Program
    {
        static void Main(string[] args)
        {
            GameState State = GameState.success;
            int num = (int)State;
            Console.WriteLine(num);//输出结果是2
            Console.ReadKey();
        }
    }
}

结构体

namespace _526结构体
{
    struct Position
    {
        public float x;
        public float y;
        public float z;
    }
    class Program
    {
        static void Main(string[] args)
        {
            Position ememy1;//使用结构体声明变量,相当于声明了结构体中的所有变量
            ememy1.x = 340;
            ememy1.y = 200;
        }
    }
}

数组的定义
定义方法一
int[] score={24,32,76,24,36,89};
方法二
int[] score;
score = new int[10]; //相当于int[] score= new int[10];
方法三
int[] score = new int[10] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };

            int[] score = new int[10] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
            char[] charArray={'a','b'};
            Console.WriteLine(charArray[1]);
            string[] Name = { "Jane", "Mike", "John" };
            Console.WriteLine(Name[2]);
            Console.ReadKey();

枚举类型是有限的几种 可以举例出来的
结构体是一个变量有不同的属性 便以定义
数组是一组数据

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值