Those who prefer reading this site through RSS now can also subscribe for updates to .NET Tips & Tricks Community.
C# 2.0 allows you to explicitly suppress and restore compiler warnings using the #pragma warning directive:
// Disable "The private field 'MyClass._number' is never used" warning
#pragma warning disable 169
public class MyClass
{
int _number;
}
#pragma warning restore 169
Disabling warnings should be generally discouraged in production code. It is intended only for analysis when trying to isolate a problem, or when you lay out the code and would like to get the initial code structure in place without having to polish it up first. In all other cases, avoid suppressing compiler warnings.