Quantcast
Channel: Programming (In-game)
Viewing all articles
Browse latest Browse all 645

where Statement not working?

$
0
0
Hi,

I'm trying to make a function, that directly gives me a List<T> instead of the List<IMyFunctionalBlock>!

My first attempt:
Code:
public List<T> getAllBlocksOfType<T>()
where T : IMyTerminalBlock
{
    List<IMyTerminalBlock> b = new List<IMyTerminalBlock>();
    GridTerminalSystem.GetBlocksOfType<T>(b);
    List<T> c = new List<T>();
    foreach (IMyTerminalBlock a in b)
        if((a as T)!=null) // This should always be true, but throws an Error on "Check Code" (see below)...
where Statement not working?

Viewing all articles
Browse latest Browse all 645

Trending Articles