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 9200637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:48:42+00:00 2026-06-17T22:48:42+00:00

How do I use Overloading method for this example. When I send an increment,

  • 0

How do I use Overloading method for this example. When I send an increment, it should give me the new value. If I don’t give an increment, it should add a default value. This is in c# asp.net.

For example:

 GetY(y,3)  // add 3 to y 

 or GetY(y) //add default value of 15

Thank you!

  • 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-17T22:48:44+00:00Added an answer on June 17, 2026 at 10:48 pm

    You can use an optional parameter to specify a default value, and then overloading isn’t necessary.

    public int GetY(int y, int add = 15) {
        return y + add;
    }
    

    This is the same as the following overloaded version:

    public int GetY(int y) {
        return GetY(y, 15);
    }
    
    public int GetY(int y, int add) {
        return y + add;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Many system calls in Unix use overloading and default variables. This concept is absent
Possible Duplicate: Generic methods and method overloading Ok, I hit this one by accident...
I have been researching switching my allocation method from simpling overloading new to using
I am trying to use predicates, but I can't because method overloading is acting
I use method overloading as below in my Javascript code. function somefunction() { //1st
I'm trying to use operator overloading to define the basic operations (+,-,*,/) for my
use Text::Table; my $tb = Text::Table->new(Planet,Radius\nkm,Density\ng/cm^3); $tb->load( [ Mercury,2360,3.7], [ Mercury,2360,3.7], [ Mercury,2360,3.7], );
use Modern::Perl; use Algorithm::Permute; use List::AllUtils qw/uniq/; find_perms(1151); sub find_perms { my ($value) =
Edit: Changed question title from Does C# allow method overloading, PHP style (__call)? -
Possible Duplicate: Really impossible to use return type overloading? Is there a way to

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.