I have 2 class lists,
List<CommunityGroups> List1=new List<CommunityGroups>(); List<CommunityGroups> List1=new List<CommunityGroups>(); public class CommunityGroups { public long CommunityID { get; set; } public string CommunityName { get; set; } } In these lists, List1 10 CommunityGroups which has both CommunityID and CommunityName. List2 contais 5 CommunityGroups which has CommunityID and blank CommunityNames. I need to populate the CommunityNames in List2 with respect to List1. Now I am using the code,
for (int i = 0; i < List2.Count; i++) { for (int j = 0; j < List1.Length; j++) { if (List2[i].GroupId == List1[j].Id) { List2[i].GroupName = List1[j].Name; } } } } I need to use linq query for this purpose. How can I replace these code with linq. Please someone help me.
Thanks
GroupId,GroupName,NameandIddefined inCommunityGroups?