How to perform LINQ query over Enum?

前端 未结 6 586
梦如初夏
梦如初夏 2021-02-03 19:42

Below is my Enumerator List:

public enum StatusEnum
{
    Open = 1,
    Rejected = 2,
    Accepted = 3,
    Started = 4,
    Completed = 5,
    Canc         


        
6条回答
  •  执笔经年
    2021-02-03 19:54

    ". . . only show the first 4 statuses and ignore the rest."

    To get the first n elements of an IEnumerable, use the Take method:

    return Enum.GetValues(typeof(Activity.StatusEnum))
        .Cast()
        .Take(4)
        .ToList();
    

提交回复
热议问题