Disable Warning for Unused Variable

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?
 
D

Dave Sexton

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;
}
 
B

Bill Rodenbaugh

#pragma warning disable PUT_WARNING_NUMBER_HERE

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


#pragma warning restore PUT_WARNING_NUMBER_HERE
 

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