I have a method (shown below) that I discovered can be reused in code elsewhere if I could turn it into a generic method, but am struggling with the syntax and could use a bit of help:
Sample:
private List<IndexEntry> AddParentReferences(List<IndexEntry> listWithoutParents)
{
List<IndexEntry> listWithParents = new List<IndexEntry>();
foreach (IndexEntry currentEntry in listWithoutParents)
{
if (currentEntry.SubEntries == null || currentEntry.SubEntries.Count < 1)
{
listWithParents.Add(currentEntry);
continue;
}
AddIndividualParentReference(currentEntry);
listWithParents.Add(currentEntry);
}
return listWithParents;
}
As you can see it's a simple method that takes in a List of IndexEntry types and enumerates that list adding references to parent items in the hierarchy. I've discovered that there are similarly designed types that will also need this sort of reference added at various points. I'd like to modify this code to take in a List and return an appropriate List where T is the type passed in. This seemed like a straight forward method to write, but I think I may be missing a simple sytax issue in my method definition. Can anyone enlighten me?
Thanks in advance,
Steve