Easiest way to merge two List<T>s

Posted by Chris McCall on Stack Overflow See other posts from Stack Overflow or by Chris McCall
Published on 2010-03-15T22:28:32Z Indexed on 2010/03/15 22:49 UTC
Read the original article Hit count: 152

Filed under:
|

I've got two List<Name>s:

public class Name
        {
            public string NameText {get;set;}
            public Gender Gender { get; set; }
        }

public class Gender
        {
            public decimal MaleFrequency { get; set; }
            public decimal MaleCumulativeFrequency { get; set; }
            public decimal FemaleCumulativeFrequency { get; set; }
            public decimal FemaleFrequency { get; set; }
        }

If the NameText property matches, I'd like to take the FemaleFrequency and FemaleCumulativeFrequency from the list of female Names and the MaleFrequency and MaleCumulativeFrequency values from the list of male Names and create one list of Names with all four properties populated.

What's the easiest way to go about this in C# using .Net 3.5?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ienumerable