LoginSignup
46
34

More than 5 years have passed since last update.

enumの項目数を取得する

Posted at

enum a{A,B,C};の項目数が欲しいとき、a.Lengthなどとは出来ません。
どうしても項目数が欲しいときは、以下のようにします。

sample.cs
Enum.GetNames(typeof(a)).Length
46
34
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
46
34