objectList.Find( delegate(EngineObject obj) { return obj.ID == objectId; } );
This also does not work?
[quote name='Capoeirista' timestamp='1347913255' post='4981007']
I looked up how to use LINQ, and the following does work :
That method will always return default(T).
But as an aside, if you're going to look up an object by its id, why not use a dictionary for the collection of EngineObjects as well?
public T GetObject<T>(int objectId) where T : EngineObject
{
Dictionary<int, EngineObject> objects;
if (m_objectInstances.TryGetValue(typeof(T), out objects))
return (T)objects[objectId];
else
return default(T);
}
private Dictionary<Type, Dictionary<int, EngineObject>> m_objectInstances;
[/quote]
I think he knows that will only return Default(T), as he commented the section that was actually going to do something to test the part of the code where he's having issues.