• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

FindAll in List of Objects Containing List

I have a list of objects containing a list of other objects, and I'm wondering if there's a way to use List.FindAll (or anything else really... other than writing looping constructs) to get a list returned of LogInfo objects whose aliases list member contains a specific name value.

List<LogInfo> Translation = new List<LogInfo>();

public class LogInfo
            public string existingName;
            public string newName;
            public int existingLSN;
            public string desc;
            public string units;
            public int rule;
            public List<AliasLog> aliases = new List<AliasLog>();

        public class AliasLog
            public string name;
            public int lsn;

Open in new window

  • 2
1 Solution
tempList = list.FindAll(x=>x.aliases.Exists(y=>y.name == yourStringToCompare));

//i did not test this on my end.
diablo089Author Commented:
I think this works. Short and sweet. Thank you very much.
you are welcome

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now