Disable Warning for Unused Variable

  • Thread starter Thread starter O.B.
  • Start date Start date
O

O.B.

Is there a tag that I can use to designate that a parameter is not used
and thus, not flag a compiler warning?

For example:

public struct MyClass {
public int header;
private int padding_;
}

The compiler complains that padding_ is not used. That is the desired
behavior in that it is used merely as padding in memory. I don't want
to disable all compiler warnings; just this particular instance. Does
C# support this?
 
Hi,

You don't need to add arbitrary properties:

[System.Runtime.InteropServices.StructLayout(
System.Runtime.InteropServices.LayoutKind.Sequential,
Size=8)]
public struct MyClass // shouldn't be named Class ;)
{
public int header;
}
 
#pragma warning disable PUT_WARNING_NUMBER_HERE

public struct MyClass {
public int header;
private int padding_;
}


#pragma warning restore PUT_WARNING_NUMBER_HERE
 
Back
Top