5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

範囲外の enum

5
Last updated at Posted at 2013-08-23

以下の内容は enum 利用時の注意事項について により詳しく書かれています。


enum は範囲外の値もとれるってことが意外と知られていない気がする。

enum.cs
public enum Hoge
{
    Foo = 0,
    Bar = 1
}
use.cs
// 普通に動く
Hoge hoge = (Hoge) 2;
5
5
1

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
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?