-1
我想知道我們是否可以重寫WCF方法或Web服務方法。如果是這樣,那麼怎麼樣?我們可以重寫WCF或Web服務中的方法嗎?
我想知道我們是否可以重寫WCF方法或Web服務方法。如果是這樣,那麼怎麼樣?我們可以重寫WCF或Web服務中的方法嗎?
試試這個重載WCF服務的方法
[ServiceContract]
public interface IMyCalculator
{
[OperationContract(Name="AddFloats")]
float Add(float operand1, float operand2);
[OperationContract(Name="AddIntegers")]
int Add(int operand1,int operand2);
}
方法覆蓋是不可能在WCF只能實現方法重載在這個崗位作爲解釋。
即使我給下面的代碼的方法重載:
[ServiceContract]
public interface IMyCalculator
{
[OperationContract(Name="AddFloats")]
float Add(float operand1, float operand2);
[OperationContract(Name="AddIntegers")]
int Add(int operand1,int operand2);
}
雖然答案是正確的,你應該說明的是,在生成的合同,不可能有過載,因此指定不同的操作名稱。 –
感謝您的回答,但我的問題是關於重寫不超載。 – Ashad