By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,910 Members | 1,077 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,910 IT Pros & Developers. It's quick & easy.

Disable Warning for Unused Variable

P: n/a
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?
Oct 25 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

You don't need to add arbitrary properties:

[System.Runtime.InteropServices.StructLayout(
System.Runtime.InteropServices.LayoutKind.Sequenti al,
Size=8)]
public struct MyClass // shouldn't be named Class ;)
{
public int header;
}

--
Dave Sexton

"O.B." <fu******@bellsouth.netwrote in message
news:12*************@corp.supernews.com...
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?

Oct 26 '06 #2

P: n/a
#pragma warning disable PUT_WARNING_NUMBER_HERE

public struct MyClass {
public int header;
private int padding_;
}
#pragma warning restore PUT_WARNING_NUMBER_HERE

On Oct 25, 3:37 pm, "O.B." <funkj...@bellsouth.netwrote:
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?
Oct 26 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.