C# 枚举(enum)特性
using 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。