Which code segment should you use?

You create a Windows Communication Foundation service by using Microsoft .NET Framework 3.5.
The service contains the following code segment.

[DataContract]
public class Person{ }
[DataContract]
public class Customer: Person{ }

You need to create a service contract that meets the following requirements:
The service contract must have an operation contract named GetPerson that returns an object of Type Person.
The GetPerson operation must be able to return an object of Type Customer.
Which code segment should you use?

You create a Windows Communication Foundation service by using Microsoft .NET Framework 3.5.
The service contains the following code segment.

[DataContract]
public class Person{ }
[DataContract]
public class Customer: Person{ }

You need to create a service contract that meets the following requirements:
The service contract must have an operation contract named GetPerson that returns an object of Type Person.
The GetPerson operation must be able to return an object of Type Customer.
Which code segment should you use?

A.
[ServiceContract]
[ServiceKnownType("GetPerson")]
public interface IMyService
{
[OperationContract]
Person GetPerson();
}

B.
[ServiceContract]
public interface IMyService
{
[OperationContract]
[ServiceKnownType("Customer")]
Person GetPerson();
}

C.
[ServiceContract]
[ServiceKnownType(typeOf(Customer))]
public interface IMyService
{
[OperationContract]
Person GetPerson();
}

D.
[ServiceContract]
[ServiceKnownType("GetPerson",typeOf(Customer))]
public interface IMyService
{
[OperationContract]
Person GetPerson();
}



Leave a Reply 0

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