Cast List to List in .NET 2.0

后端 未结 8 2124
抹茶落季
抹茶落季 2020-12-07 15:28

Can you cast a List to List somehow?

I know I could loop through and .ToString() the thing, but a cast would be aw

8条回答
  •  失恋的感觉
    2020-12-07 15:52

    Is C# 2.0 able to do List.Convert? If so, I think your best guess would be to use that with a delegate:

    List list = new List();
    list.Add(1);
    list.Add(2);
    list.Add(3);
    list.Convert(delegate (int i) { return i.ToString(); });
    

    Something along those lines.


    Upvote Glenn's answer, which is probably the correct code ;-)

提交回复
热议问题