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 877873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:40:57+00:00 2026-05-15T11:40:57+00:00

I will use the Starter Example given when you create a WCF Service [DataContract]

  • 0

I will use the Starter Example given when you create a WCF Service

[DataContract]
public class CompositeType
{
    bool boolValue = true;
    string stringValue = "Hello ";

    [DataMember]
    public bool BoolValue
    {
        get { return boolValue; }
        set { boolValue = value; }
    }

    [DataMember] 
    public string StringValue
    {
        get { return stringValue; }
        set { stringValue = value; }
    }
}

When I use DataContract everything is ok.

When I use Serializable, the actual variables, whether private or public are visualable to the host and not the Properties. If I use NonSerialized it does hide the variable but it doesn’t get passed either. I get that, and I think I get why the properties are not passed because there is nothing to serialize? Is that correct?

[Serializable]
public class CompositeType
{
    [NonSerialized]
    bool boolValue = true;
    [NonSerialized]
    string stringValue = "Hello ";


    public bool BoolValue
    {
        get { return boolValue; }
        set { boolValue = value; }
    }


    public string StringValue
    {
        get { return stringValue; }
        set { stringValue = value; }
    }
}

If I do not supply any attributes, the class gets returned as expected, and this I do not understand?

I am tasked with taking existing business objects and working with them through WCF? It looks like my best option is to leave them alone instead of adding a DataContract attribute. Why is that?

  • 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-15T11:40:57+00:00Added an answer on May 15, 2026 at 11:40 am

    The [DataContract] attribute is optional.

    Why ever use it, then? It lets you control what and how your data is serialized — for example, which properties are to be included & excluded.

    If you can get by without it, that is fine, but you may soon find that you need greater control over what and how data gets sent over the wire.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I will use quickaction for a listview. I use this example for quickaction: http://www.londatiga.net/it/how-to-create-quickaction-dialog-in-android/
I will use std::map<int, A> A is a class and I have to prevent
I will use (again) the following class hierarchy: Event and all the following classes
I will use the following javascript to display a Google Map Window in a
When we will use DrawItem for a listbox? Normally, if the listbox is ownerdraw,
My script below will use two external tables to fill two separate tables, but
im writing c# app in VS2008 that will use some reports. My question: how
I want to start an application which will use ajax push, however the web
When Excel determines the axis values it will use to represent your data in
We are writing an app that will use T4 to generate Flex/Actionscript to compile

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.