Does anyone know how to suppress a specific warning for a line or block of
code in C#? C++ has a nice facility to disable a warning for a block of code
with #pragma for warnings that are incorrect or don't apply.
For example, the following code generates an CS0628 because CS0628 makes an
incorrect assumption that "protected" applies only to inheritance:
public sealed class Class
{
EmbeddedClass utility = new EmbeddedClass();
protected static void StaticFunction() // CS0628
{
}
protected void InstanceMethod() // CS0628
{
}
private class EmbeddedClass
{
public EmbeddedClass()
{
Class.StaticFunction(); // call to "uncallable" function
new Class().InstanceMethod(); // call to "uncallable" function
}
}
}
--
http://www.peterRitchie.com/