2019年8月23日 星期五

How do I enumerate an enum in C#?

foreach (Suit suit in (Suit[]) Enum.GetValues(typeof(Suit)))
{
}
Note: The cast to (Suit[]) is not strictly necessary, but does make the code 0.5 ns faster.

from : https://stackoverflow.com/questions/105372/how-do-i-enumerate-an-enum-in-c

沒有留言:

張貼留言