Event never used warning message

  • Thread starter Thread starter Jack Addington
  • Start date Start date
J

Jack Addington

I have created an event and delegate combination for use in a user control
when I place it on a form. However because I'm not actually doing anything
in the event in the user object I didn't create any code for it.

1) How do I get rid of that warning (besides creating an empty declaration)
2) What is the best practice for declaring new events

thx

jack
 
Jack,

I think the warning is because the event is never being fired anywhere
from within your class. The compiler is issuing the warning because it is
wondering why you have an event that you never fire.

You can go to the project properties and set it so that the compiler
will not issue warnings below a certain level. You can also include
warnings you would like to ignore. However, as a matter of general
principal, I would say that this is a bad thing. I would recommend treating
warnings as errors, and strive for no compilation errors.

Hope this helps.
 
I agree that I don't want to changd the compiler warning level and I know
why the warning is happening, but what is the 'recommended' thing to do in
this case?

Should I add an empty event to my class?

Nicholas Paldino said:
Jack,

I think the warning is because the event is never being fired anywhere
from within your class. The compiler is issuing the warning because it is
wondering why you have an event that you never fire.

You can go to the project properties and set it so that the compiler
will not issue warnings below a certain level. You can also include
warnings you would like to ignore. However, as a matter of general
principal, I would say that this is a bad thing. I would recommend
treating warnings as errors, and strive for no compilation errors.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Jack Addington said:
I have created an event and delegate combination for use in a user control
when I place it on a form. However because I'm not actually doing
anything in the event in the user object I didn't create any code for it.

1) How do I get rid of that warning (besides creating an empty
declaration)
2) What is the best practice for declaring new events

thx

jack
 
Back
Top