Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 518443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:56:16+00:00 2026-05-13T07:56:16+00:00

I have some simple POCO object: public class ProductCategoryDTO { public string Name {

  • 0

I have some simple POCO object:

public class ProductCategoryDTO
{
        public string Name { get; set; }
        public DateTime ModifiedDate { get; set; }
}

As sometimes field order is important (for example, if sending to Infopath forms), I need to keep element order when serializing.

And now I am confused, what attributes I should use for the class and for each field. I know that:

  • DataContractSerializer uses [DataContract] and [DataMember(Order = n)]
  • XMLSerializer uses [Serializable] and [XmlElementAttribute(Order = n)].

Then what attributes to use if I want to support both XMLSerializer and DataContractSerializer, so it can used in both WCF or ASP. web services?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:56:17+00:00Added an answer on May 13, 2026 at 7:56 am

    I don’t see any reason why you couldn’t put both attributes on the class and member properties, if you really must. Doesn’t look nice, but if it works for you, that’s just fine!

    [DataContract(Namespace="....")]
    [XmlType]
    public class ProductCategoryDTO
    {
            [DataMember(Order=1)]
            [XmlElementAttribute(Order=1)]
            public string Name { get; set; }
    
            [DataMember(Order=2)]
            [XmlElementAttribute(Order=2)]
            public DateTime ModifiedDate { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have some simple data y = [[datetime.datetime( 2012,1,1,1,1), 2.1], [datetime.datetime( 2012,1,1,1,2),
I have some very simple XML: <properties> <property> <name>BobFish</name> <explaination>Bob is a fish.</explaination> </property>
I have some simple SOAP client to get data from WSDL and display it.
I have a simple poco class that has an enum property (Needed so that
I have some simple constraints involving multiplication of reals in z3 that are producing
I have some simple JQuery / Javascript to perform some simple logic for all
I have some simple markup: <table> <tr> <td>Menu Item</td> </tr> </table> <div> <table> <tr>
i have some WinForms app (Framework to develop some simple apps), written in C#.
i have some WinForms app (Framework to develop some simple apps), written in C#.
CSS I have some simple CSS to apply a negative text-indent value on the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.