WCF Interview questions: - Can we do method overloading in WCF service?

 Posted by ArticlesMaint on 2/14/2012 | Category: WCF Interview questions | Views: 11772

Many developers would answer this question as Yes because C# is used in WCF and C# is Object oriented, so a natural thinking would be WCF should also support method overloading.

The fact is it does not, surprised right :-). If you have a method which is overloaded you need to use the "Name" parameter in the "OperationContract" to ensure that the proxy class generates different names.

See the below code for more details. In the below code we have "GetData" which is overloaded but we are saying to the client to generate the methods with name "GetData" and "GetData1".


public interface IService1

string GetData(int value);

string GetData(int value, int value1);

// TODO: Add your service operations here

Do also see the below video why practically we can not do method overloading in WCF service: -

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Akiii on: 2/15/2012
great question...

Thanks and Regards

Login to post response