I have a finalised class called SimObject
. In this class, there is a public function called Draw()
.
Instead of extending and overriding from SimObject
in another new class, I would like to assign a method to replace Draw()
from my Main class. The Main class creates the SimObject
and holds an instance of it. So how can I do something like this:
public class Main {
public static void Main() {
//constructor
var obj = new SimObject();
obj.Draw = MyNewDrawMethod;
}
public void MyNewDrawMethod() {
//some code
}
}
Is this possible in c#?