Convert List to IEnumerable

前端 未结 6 1434
囚心锁ツ
囚心锁ツ 2020-12-29 01:59

Tricky problem here. I\'m trying to convert items for a list to IEnumerable.

Lists

dynamicTextInDatabase si

6条回答
  •  误落风尘
    2020-12-29 02:17

    If you need to convert a List of objects (without Enums) to IEnumerable, you can use a declarative style of LINQ:

    var items = from TipoDoc t in tipoDocs
                    select new SelectListItem {Value = t.Id, Text = t.Description};
    

    Here, tipoDocs is a List of objects of type TipoDoc

    public class TipoDoc
    {
        public string Id { get; set; }
        public string Description { get; set; }
    }
    

提交回复
热议问题