class Flarg
{
private readonly Action speak;
public Action Speak
{
get
{
return speak;
}
}
public Flarg(Act
Remember that a delegate consists of two parts:
When calling the base constructor, the method is know, but the target instance isn't yet constructed.
So, you can omit the target instance, creating an open delegate. The easiest way to do this is using a lambda:
class Flarg
{
private readonly Action speak;
public Action Speak
{
get
{
return this.speak;
}
}
public Flarg(Action speak)
{
this.speak = () => speak(this);
}
}
class MuteFlarg : Flarg
{
public MuteFlarg() : base(x => ((MuteFlarg)x).GiveDumbLook())
{
}
private void GiveDumbLook()
{
}
}