KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a class with some virtual functions, let's pretend this is one of them: public class AClassWhatever { protected virtual string DoAThingToAString(string inputString) { return inputString + "blah"; } } I want to instantiate this class while overriding "DoAThingToAString" inline, much like I can declare properties inline in a declaration, as follows: ... AClassWhatever instance = new AClassWhatever { DoAThingToAString = new function(string inputString) { return inputString + inputString + " fill my eyes." } } ... And now for "instance", DoAThingToAString is overridden with that definition. I need to be able to define the default behavior in the class definition and only override it as needed, differently different times, and I don't want to proliferate a bunch of subclasses to do this. I know I need to use delegates or something similar, but I've been out of the syntax game for way too long and google was giving me too much irrelevant info.
Tags (comma-separated)
Save Edits
Cancel