Hello everyone. I'm new to c# and I'm trying to use some delegates in my
code, so I can do time-tests on whatever I'm doing. In order to do this I
tried writing a testing method that will make use of a stopwatch and will
take as a parameter a delegate. I've seen this done by Nicholas Paldino in a
post and I tried to reproduce it (not copy-paste, but re-type and try to
understand).
So I start a new Console application project, I remove all the comments so I
can focus on my code, and I get what you'll see further down in this post.
Unfortunately the C# compiler doesn't like my code and I'm stuck on a VERY
basic concept:
(Q) How do I pass an delegate to a function that is supposed to accept one?
On my code I get this error:
"C:\...\Class1.cs(15): Method 'ConsoleApplication5.Class1.Dummy1()'
referenced without parentheses"
Here's my code:
using System;
namespace ConsoleApplication5
{
class Class1
{
public delegate void DummyTest();
public void Dummy1()
{}
public void DummyConsummer(DummyTest test)
{}
static void Main(string[] args)
{ DummyConsumer(Dummy1); } // Error line
}
}