Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'System.Collections.Generic.List

后端 未结 5 1190
Happy的楠姐
Happy的楠姐 2020-11-29 09:21

I have the code below:

List aa = (from char c in source
                   select new { Data = c.ToString() }).ToList();

But

5条回答
  •  再見小時候
    2020-11-29 09:41

    If you want it to be List, get rid of the anonymous type and add a .ToList() call:

    List list = (from char c in source
                         select c.ToString()).ToList();
    

提交回复
热议问题