c# - Code clarity for converting generic list? -


This code should be changed to the list of listType2s (list) list type1s. I think that although the functionality is difficult to detect.

I'm looking for alternative methods that are easy to read, yet brief and concise.

  list & lt; Type1 & gt; Type1s = new list & lt; Type1 & gt; (); List Type 2 Foryeich (t = & gt; add 1 type ((new type 1 (t)))); I generally agree to use LINQ for this type of thing - but  list & lt  

; T & gt; has been a ConvertAll method since .NET 2.0, which is actually a bit more efficient (because it already knows the size):

  List & lt; Type 1 & gt; Type1s = listType2.ConvertAll (t = & gt; new type 1 (t));  

I probably do not use LINQ myself, unless I have a specific reason, just because it is in line with the rest of the code Maybe LINQ is also about


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -