Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8711631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:55:35+00:00 2026-06-13T04:55:35+00:00

I use Windows Communication Services (WCF) in my project. In my project, I write

  • 0

I use Windows Communication Services (WCF) in my project.

In my project,

I write the function like below:

GetUserNameByUserId(int userId);
GetProductInformationByProductId(int productId);

But this naming have been coming more and more complex day by day.

For instance I have 5 parameters to pass to the function, in this case the function name will be like blow:

GetStackOverFlowByStackByOverByFlowByIdByStackOverFlow(string stack, string over, string flow, int id, string stackOverFlow);

And assume that I want to get with 2 parameters like blow:

GetStackOverFlowByIdByStackOverFlow(int id, string stackOverFlow);

I want to use function overloading like below:

public void abc(int i)
{
    System.Console.WriteLine("abc" + i);
}
public void abc(string i)
{
    System.Console.WriteLine("abc" + i);
}
public void abc(string i,int j)
{
    System.Console.WriteLine("abc" + i + j);
}

That is to say, I want to write below functions:

GetStackOverFlow(int id);
GetStackOverFlow(int id, string name);
GetStackOverFlow(int id, string name, string StackOver);
.
.

Isn’t it?
Are there any methodology for that?
Or am I doing right?

I research and find this:
Function Overloading in WCF

public interface IMyService
{
   [OperationContract(Name = "GetStringWithParam")]
   string GetString(DateTime date);

   [OperationContract(Name = "GetStringWithoutParam")]
   string GetString();
}

and he said that

But i don’t prefer it as it is sometimes lead to confusion.

are there any other way?
Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:55:37+00:00Added an answer on June 13, 2026 at 4:55 am

    You could use a class as a parameter.

    [DataContract]
    public class MySearchSettings
    {
    
        [DataMember]
        public int? ID { get; set; }
        [DataMember]
        public string Name { get; set; }
        [DataMember]
        public string StackOver { get; set; }
    
    }
    

    and than create a method like this:

    public GetStackOverflowResponse GetStackOverflow(MySearchSettings searchSettings)
    {
        var response = new GetStackOverflowResponse();
        try
        {
            User user = null;
            if (searchSettings == null)
                throw new ArgumentNullException("searchSettings");
            if (searchSettings.ID.HasValue)
                user = //queryByID;
            else if (!String.IsNullOrEmpty(searchSettings.Name))
                user = //queryByName;
            else if (!String.IsNullOrEmpty(searchSettings.StackOver))
                user = //queryByStackOver;
            response.User = user;
        }
        catch(Exception e)
        {
            response.ErrorMessage = String.Format("{0}: {1}",
                                                  e.GetType().Name,
                                                  e.Message);
        }
        return response;
    }
    

    I have not included the GetStackOverflowResponse class but you get the idea of it.
    One of the benefits of this is that you could easily extend the class without breaking functionality of a client when a newer version of your Service is deployed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I like to use wcf (windows communication foundation) with windows authentication. Do I need
Microsoft was pushing Windows Communication Foundation (WCF) a while back to replace Web Services
I have to use Interprocess Communication in a Windows CE Project but I hve
I have to use windows to write some shell scripts. I decided to use
We have a WCF (Windows Communication Foundation) client and service application. We're using Windows
I am having trouble upgrading my current project to use RIA Services. I added
I am trying to use the RXTX library for blocking serial communication on Windows
I use Windows Vista and I was wondering if there was a shortcut to
We use Windows for our development systems. I am installing PHP, Apache, MySQL manually.
I use Windows 7(64bit) and repeat steps in Google Document . This is what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.