hi in post i will show how to implement method overloading in WCF using c#.net.
Example :
Take a new WCF Service Application Project.
1. IService1.cs --> Interface code
[ServiceContract]
public interface IService1
{
[OperationContract(Name="GetDataValue1")] //Method overloading
string GetData(int value);
[OperationContract(Name = "GetDataValue2")] //Method overloading
string GetData(string value);
}
2. Service.svc.cs
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
public string GetData(string value)
{
return string.Format("You entered: {0}", value);
}
}
3. Result :
Example :
Take a new WCF Service Application Project.
1. IService1.cs --> Interface code
[ServiceContract]
public interface IService1
{
[OperationContract(Name="GetDataValue1")] //Method overloading
string GetData(int value);
[OperationContract(Name = "GetDataValue2")] //Method overloading
string GetData(string value);
}
2. Service.svc.cs
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
public string GetData(string value)
{
return string.Format("You entered: {0}", value);
}
}
3. Result :
No comments:
Post a Comment