Can we overload methods in WCF Service or Web Service?

 Posted by Ddd on 1/22/2011 | Category: WCF Interview questions | Views: 7841 | Points: 40

Yes for a WCF Service use the Name property of OperationContractAttribute class
interface ddd


[OperationContract(Name = "one")]

int calc(int a,int b);

[OperationContract(Name = "two")]

double calc(double a,double b);


1)For a Web Service use the MessageName property of WebMethodAttribute class

2)Please comment the following line in the .cs file of the Web Service

//[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

public string HelloWorld(string a) {
return "Hello"+" "+a;
public string HelloWorld()
return "Hello second";

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response