adding event handlers withour new operator

  • Thread starter Thread starter bart
  • Start date Start date
B

bart

Hi,

I am very curious what is the difference between these two lines:

SomeEvent += new EventHandler(Method)

and

SomeEvent += new Method.

It bothers me lately:)
 
bart said:
Hi,

I am very curious what is the difference between these two lines:

SomeEvent += new EventHandler(Method)

This compiles, if you add a semicolon.
and

SomeEvent += new Method.

This doesn't, even if you remove the dot and add a semicolon.
It bothers me lately:)

The differences between the following two lines:

SomeEvent += new EventHandler(Method);
SomeEvent += Method;

is none, the compiler fills in the missing delegate type, as long as it
can infer it from the event.
 
This compiles, if you add a semicolon.





This doesn't, even if you remove the dot and add a semicolon.




The differences between the following two lines:

SomeEvent += new EventHandler(Method);
SomeEvent += Method;

is none, the compiler fills in the missing delegate type, as long as it
can infer it from the event.

Thanks man, now I can sleep well:)
 

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

Back
Top