Adding delegate function vs adding new delegate to event

G

Guest

If we have:

public delegate void Test(string s);
public event Test testevent;
public void log(string s) {...}

What is the difference between:

testevent += log;

and

testevent += new Test(log);

I always used the former, but all the examples I'm encountering in
documentation use the latter. Is the former incorrect for any reason?
 
M

Mattias Sjögren

Dave,
What is the difference between:

testevent += log;

and

testevent += new Test(log);


The former is less typing and only works in C# 2.0.


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top