WCF Method Overloading
نویسنده: مسعود پاکدل
تاریخ: ۱۳۹۲/۰۲/۳۰ ۲۲:۴۰
آدرس: www.dntips.ir
| مطالب | ۳۶۹۴ |
| نویسندگان | ۲۷۶ |
| گروههای مطالب | ۱۰۲۴ |
| نقشههای راه | ۱۱۹ |
| دورهها | ۱۴ |
| اشتراکها | ۱۷۹۱۴ |
[ServiceContract]
public interface ISampleService
{
[OperationContract]
int Sum( int number1, int number2 );
[OperationContract]
float Sum( float number1, float number2 );
} public class SampleService : ISampleService
{
public int Sum( int number1, int number2 )
{
return number1 + number1;
}
public float Sum( float number1, float number2 )
{
return number1 + number1;
}
}Cannot have two operations in the same contract with the same name, methods Sum and Sum in type Service.ISampleService 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.
[ServiceContract]
public interface ISampleService
{
[OperationContract( Name = "SumByIntNumbers" )]
int Sum( int number1, int number2 );
[OperationContract( Name = "SumByFloatNumbers" )]
float Sum( float number1, float number2 );
}