wesley <we*@inthemix.com.au> wrote:
I want to do the followling:
[XmlIgnoreAttribute]
[NonSerialized]
public string Id
{
get { return id; }
set { id = value; }
}
But the compiler won't let me have more than 1 attribute there. How do I
apply both attribute in my fields?
The compiler message I get is fairly clear:
<quote>
Test.cs(9,6): error CS0592: Attribute 'NonSerialized' is not valid on
this declaration type. It is valid on 'field' declarations only.
</quote>
It's got nothing to do with having multiple attributes - it's just that
Id is a property, not a field, and the NonSerialized attribute can only
apply to fields.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too