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

后端 未结 5 1194
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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-29 09:28

    If you have source as a string like "abcd" and want to produce a list like this:

    { "a.a" },
    { "b.b" },
    { "c.c" },
    { "d.d" }
    

    then call:

    List list = source.Select(c => String.Concat(c, ".", c)).ToList();
    

提交回复
热议问题