locked
Boolean/Int32 values always return false and zero RRS feed

  • Question

  • User915507249 posted

    Hi,

    I have a DataContract in WCF something like this:

    [DataContract]
        public class BookingType
        {
            [DataMember]
            public String ID { get; set; }
            [DataMember]
            public Int32 AllowBooking { get; set; }
            [DataMember]
            public Boolean Disabled { get; set; }
        }

    And when I set true/false from Client and send the data to WCF, the Boolean value reads as False all the time. And the Int32 reads 0 (zero) all time. I tried searching but no luck so far. Much appreciated.

    Ryan

    Thursday, December 5, 2013 4:08 AM

Answers

  • User260886948 posted

    Hi,

    In the .NET Framework, types have a concept of default values. For example, for any reference type the default value is null, and for an integer type it is zero. It is occasionally desirable to omit a data member from serialized data when it is set to its default value. Because the member has a default value, an actual value need not be serialized; this has a performance advantage.

    For more information, please try to refer to:
    #Data Member Default Values:
    http://msdn.microsoft.com/en-us/library/aa347792(v=vs.110).aspx .

    Best Regards,
    Amy Peng

     

               

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 9, 2013 3:25 AM