It is not possible to overload OperationContract
[ServiceContract]
public interface IOverload
{
[OperationContract]
int TestMethod(int arg1);
[OperationContract]
int TestMethod(int arg1,int arg2);
}
At run time, it will throw an exception as like
System.InvalidOperationException: Cannot have two operations in the same contract with the same name, You can change the name of one of the operations by changing the method name or by using the Name property of OperationContractAttribute.
we can set the operation contract name as below.
[ServiceContract]
public interface IOverload
{
[OperationContract(Name="Test1")]
int TestMethod(int arg1);
[OperationContract(Name="Test2")]
int TestMethod(int arg1,int arg2);
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment