C#C
C#2y ago
Theos

List not returning all matching elements

hey, I have this method
public List<T> GetStatementsOfType<T>() where T : ASTStatement
{
    return statements.OfType<T>().ToList();
} 

and i call it like this:
foreach(ASTVariableDeclaration dec in astScope.GetStatementsOfType<ASTVariableDeclaration>()) 
{
    _globalVariables.Add(dec.name.value, null);
}


for some reason it only returns one element matching that type but it should return two
image.png
Was this page helpful?