When i try to use Delegate's Method Property in C# i get this error.
'myDelegate' does not contain a definition for 'Method' and no extension method 'Method' accepting a first argument of type 'myDelegate' could be found (are you missing a using directive or an assembly reference?)
I really don't know the reason why i get this. My program is fairly simple and is based on delegates. Below it's code is given:
public delegate void myDelegate(int x);
public class Program
{
public void Main(string[] args)
{
X x = new X();
myDelegate d = x.InstanceProgress;
Console.WriteLine(d.Method);
}
}
class X
{
public void InstanceProgress(int percent) => Console.WriteLine(percent);
}
I get error on this line:
Console.WriteLine(d.Method);
See this image below, although i get the proper output but i get the error. I have marked the error with green arrow on the image.
