Reputation:
// method 1
public void RegisterPlayer(Player player)
{
var mysealedClass = new GreatSubscription
{
player_0 = player,
Subscription = this
};
Subscribe(_registeredPlayers, player, PlayerTypes.Player, mysealedClass.Register);
}
// Method 2
private void Subscribe<T>(CachedSynchronizedDictionary<T, int> subscribers,
T subscriber, PlayerTypes type, Func<bool> isRegistered) where T: Player
{
// There is some code here -- intentionally omitted, since it is irrelevant
}
// Method 3
protected virtual bool OnRegisterPlayer(Player myplayer)
{
return false;
}
// Sealed Class
private sealed class GreatSubscription
{
public Subscription NewSubscription;
public Player NewPlayer;
public bool Register()
{
return NewSubscription.OnRegisterPlayer(NewPlayer);
}
}
I want use anonymous method in Method 1 and get rid of the mysealedClass & its references but I am getting the error "Incompatible anonymous Function Signatures" on the rs
before the lambda . What am I doing wrong ?
Any help would be appreciated.
When I write method 1 as follows:
// method 1
public void RegisterPlayer(Player player)
{
Subscribe(_registeredPlayers, player, PlayerTypes.Player, rs => this.OnRegisterPlayer(player));
}
Upvotes: 0
Views: 2042
Reputation: 138051
Your lambda accepts one parameter, but isRegistered
is a Func<bool>
, which takes none. Remove the rs
parameter:
Subscribe(_registeredPlayers, player, PlayerTypes.Player, () => this.OnRegisterPlayer(player));
Upvotes: 1