38.

 

[ServiceContract]
public interface IStringReverser
{
    [OperationContract]
    string ReverseString(string value);

    [OperationContract]
    string ReverseString(char[] value);
}

Overloading WCF methods. Is this run time error ?

Cannot have two operations in the same contract with the same name, methods ReverseString and ReverseString in type WCFServer.IStringReverser violate this rule. You can change the name of one of the operations by changing the method name or by using the Name property of OperationContractAttribute.

By default, every operation contract gets a name that is set to the name of method. In WCF, you cannot have two operation contracts with the same name. Fortunately, this is very easy to fix by simply setting the name property of the operation contract attribute.

[ServiceContract]
public interface IStringReverser
{
    [OperationContract(Name = "ReverseStringFromString")]
    string ReverseString(string value);

    [OperationContract(Name = "ReverseStringFromCharArray")]
    string ReverseString(char[] value);
}