473,322 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Using two attributes in 1 field.

Hello,

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?

Thanks,
wes
Jul 21 '05 #1
2 2271
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
Jul 21 '05 #2
What is the error. Attributes can be written to only work on certain
objects. Maybe one of those attributes cannot work on a property.

....

After looking at the documentation for NonSerialization, it can only be
applied to fields, not properties.
"wesley" <we*@inthemix.com.au> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hello,

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?

Thanks,
wes

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Greg Lindstrom | last post by:
Hello- I have created a class, FixedLengthRecord.py, that allows me to manipulate fixed length records in the routines I write. I recently converted it to read record layouts from an SQL server...
5
by: Carlos Ribeiro | last post by:
Hello all, I'm posting this to the list with the intention to form a group of people interested in this type of solution. I'm not going to spam the list with it, unless for occasional and...
3
by: Dan Sikorsky | last post by:
How can I get the recordset attributes for a table field in SQL Server 2000 to report the field updatable attribute correctly ... mine keeps saying the fields are not updatable? That is, (...
4
by: R | last post by:
Hello everybody. I've got my XML file with 'field' node . Field is transformed with XSLT into paragraph tag in XHTML. But. A programmer can add various attributes to <field> node, eg....
2
by: MLH | last post by:
I would like to modify the following Access Basic code in Access 2.0 app so the field would an automatic counter-type field. Dim DefaultWorkspace As WorkSpace, CurrentDatabase As Database Dim...
8
by: doomx | last post by:
I'm using SQL scripts to create and alter tables in my DB I want to know if it's possible to fill the description(like in the Create table UI) using these scripts. EX: CREATE TABLE(...
4
by: davearkley | last post by:
I've recently 'discover' the wonders of custom attributes and reflection. There's one aspect that has stumping me and I've been unable to find samples in the docs or on the web. I have fields in...
2
elamberdor
by: elamberdor | last post by:
Hi All! Well, i'm modifying a dynamic map, with lat and long datapoints, my problem is it loads in text perfectly onto exact points I specify on the map, ..well now I want to load in...
65
by: Arjen | last post by:
Hi, Form a performance perspective, is it wise to use the ref statement as much as possible? Thanks! Arjen
1
by: TomGo | last post by:
Hi All I want to read out the properties of a field by the instance, which is referenced by the corresponding field. I want to read out the attributes. In a class I wrote the following: ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.