I have the following class hierarchy:
public class AI { public AI() { } public virtual void Update(float frameTime) { } } public class Boss : AI { public Boss() : base() { } public override void Update(float frameTime) { Console.WriteLine("Boss Update"); } }
I have a Symbol that contains an AI variable that then stores a Boss instance and try to use it as such to get the Boss Update function, not the base class.
AI ai = new Boss(); (Boss)ai.Update(0f);
This does not work, but what is the correct method for doing this in C #? It worked correctly with another class of AI, where I didn’t even need to drop it at all, it just ran the correct version of Update, so I had to change something inadvertently.
Shawn source share