If I have classes of Type A and B:
public class A { public int TotalCount; public string Title; } public class B { public int Count; public string Title; }
I have a list of instances A instances, what is the most efficient way to create and populate a List of type B using Linq?
List<B> listB = listA.Select(a => new B() { Count = a.TotalCount, Title = a.Title }).ToList();
Does the same as eduncan's solution with different syntax. Take your pick..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With