Are compiler #Pragma equivalents supported in C#?

G

Gary James

I'm looking for a way to suppress the CS0659 compiler warning message about
class overrides Equals but does not provide a GetHashCode() override. In
C++ VS allows this through the use of the #Pragma statement. Does VS.NET
have the equivalent?

Gary ...
 
N

Nicholas Paldino [.NET/C# MVP]

Gary,

Pragma statements are not part of the C# language. However, you can
suppress the warning options through the /nowarn flag (if using CSC on the
command line). This allows you to specify which warnings to not have
appear.

Also, you can set the properties on the project to ignore these
warnings, by going to the properties for the project, and then going to
"Configuration Properties | Build". There is a property "Suppress Specific
Warnings" which you want to set to the warnings you want to suppress.

Hope this helps.
 

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