I am having problems with a small piece of code.
I have a list of MapItem classes with two properties, Address and Html, and I need to combine the Html properties for each element with the identical Address property For example:
firstMapItem = new MapItem { Address = "1122 Elm Street", Html="<p>some html</p>" }; secondMapItem = new MapItem { Address = "1122 Elm Street", Html="<p>different html</p>" };
will become:
firstMapItem.Address == "1122 Elm Street"; firstMapItem.Html == "<p>some html</p><p>different html</p>"; secondMapItem.Address == "1122 Elm Street"; secondMapItem.Html == "<p>some html</p><p>different html</p>";
This is what I have tried so far:
foreach (MapItem item in mapItems) { var sameAddress = from m in mapItems where m.Address == item.Address select m; if (sameAddress.Count() > 1) {
I probably make it more complicated than it should be.
Thanks in advance.
source share