2013-07-23 124 views

回答

1

試試這個重載WCF服務的方法

[ServiceContract] 
public interface IMyCalculator 
{ 
     [OperationContract(Name="AddFloats")] 
     float Add(float operand1, float operand2); 

     [OperationContract(Name="AddIntegers")] 
     int Add(int operand1,int operand2); 
} 
+1

雖然答案是正確的,你應該說明的是,在生成的合同,不可能有過載,因此指定不同的操作名稱。 –

+1

感謝您的回答,但我的問題是關於重寫不超載。 – Ashad

0

方法覆蓋是不可能在WCF只能實現方法重載在這個崗位作爲解釋。

即使我給下面的代碼的方法重載:

[ServiceContract] 
public interface IMyCalculator 
{ 
     [OperationContract(Name="AddFloats")] 
     float Add(float operand1, float operand2); 

     [OperationContract(Name="AddIntegers")] 
     int Add(int operand1,int operand2); 
} 
相關問題