I am iterating through a collection of KeyValuePair, then copying the Key and Value to a newly-created class as follows :
Classes.MemberHierarchy membHier = new Classes.MemberHierarchy();
List<Classes.MemberHierarchy> membHierList = new List<Classes.MemberHierarchy>();
foreach (KeyValuePair<string, string[]> acct in acctData)
{
membHier.entityName = acct.Key;
membHier.Accounts = acct.Value;
membHierList.Add(membHier);
}
Problem is that upon the 2nd iteration, membHierList properties are immediately getting overwritten by the values in the first iteration. It's very strange.
So upon first iteration, membHier.entityName is "ABC Member" and the Accounts get populated with the string array no problem.
Then upon 2nd iteration, membHier.entityName is "XYZ Member".
Now "XYZ Member" occupies both slots as follows
membHierList[0].base.entityName = "XYZ Member" membHierList[1].base.entityName = "XYZ Member"
Do I have an object conflict up above ?
Thank you in advance.... Bob