Which code segment should you use?

You are creating a Windows Communication Foundation service by using Microsoft .NET Framework 3.5. You need to ensure that the service can send data in the following format to the client applications.

<Account Id=””>
<Name></Name>
<Balance Currency=””></Balance>
</Account>
Which code segment should you use?

You are creating a Windows Communication Foundation service by using Microsoft .NET Framework 3.5. You need to ensure that the service can send data in the following format to the client applications.

<Account Id=””>
<Name></Name>
<Balance Currency=””></Balance>
</Account>
Which code segment should you use?

A.
[Serializable]
public class Account
{
[XmlAttribute]
public string Id;
[XmlElement]
public string Name;
[XmlAttribute]
public string Currency;
[XmlElement]
public double Balance;
}

B.
[DataContract]
public class Account
{
[DataMember(Order=0)]
public string Id;
[DataMember(Order=1)]
public string Name;
[DataMember(Order=0)]
public double Balance;
[DataMember(Order=1)]
public string Currency;
}

C.
[Serializable]
public class Account
{
[XmlAttribute]
public string Id;
public string Name;
[XmlElement(“Balance”)]
public BalanceVal Balance;
}
[Serializable]
public class BalanceVal
{
[XmlText]
public double Amount;
[XmlAttribute]
public string Currency;
}

D.
[DataContract]
public class Account
{
[DataMember(Order=0)]
public string Id;
[DataMember(Order=1)]
public string Name;
[DataMember(Name=”Balance”, Order=2)]
public BalanceVal Balance;
}
[DataContract]
public struct BalanceVal
{
[DataMember(Order=0)]
public double Balance;
[DataMember(Order=1)]
public string Currency;
}



Leave a Reply 0

Your email address will not be published. Required fields are marked *