C# 枚举(enum)特性 Eicy 2023-01-19 (Updated: 2023-12-18) C# C# 1234567891011121314151617181920212223using System.Collections;using System.Collections.Generic;using UnityEngine;public class Player : MonoBehaviour{ // Start is called before the first frame update enum Gender { male, female = 8, unkonw } void Start() { print((int)Gender.male); } // Update is called once per frame void Update() { }} 枚举中的项实际上可以表示为从0开始的整数,当给其中一项赋值为n时,其后一项会变为n+1。