class Test { public delegate void FruitDelegate(Fruit f); public void Notify<T>(Action<T> del) where T : Fruit { FruitDelegate f = del;
Fruit is an empty class. Both of these delegates have the same signature.
I can't seem to do anything. Maybe this will help if I explain what I'm trying to do (indicate some context).
I want to create a class that has a common static method that provides the type and method of the method callback (for example, the above example).
The problem I am facing is that the delegate contains a parameter, and I do not want it to be entered in a method callback. For example, I want this:
public void SomeMethod() { Test.Notify<Apple>(AppleHandler); } private void AppleHandler(Apple apple) { }
Instead of this:
public void SomeMethod() { Test.Notify<Apple>(AppleHandler); } private void AppleHandler(Fruit fruit) { Apple apple = (Apple)fruit; }
Is it possible? Worked on it for several hours without much luck = /
source share