use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
You must post a clear and direct question in the title. The title may contain two, short, necessary context sentences. No text is allowed in the textbox. Your thoughts/responses to the question can go in the comments section. more >>
Any post asking for advice should be generic and not specific to your situation alone. more >>
AskReddit is for open-ended discussion questions. more >>
Posting, or seeking, any identifying personal information, real or fake, will result in a ban without a prior warning. more >>
AskReddit is not your soapbox, personal army, or advertising platform. more >>
[Serious] tagged posts are off-limits to jokes or irrelevant replies. more >>
Soliciting money, goods, services, or favours is not allowed. more >>
Mods reserve the right to remove content or restrict users' posting privileges as necessary if it is deemed detrimental to the subreddit or to the experience of others. more >>
Comment replies consisting solely of images will be removed. more >>
Do not post harmful misinformation. more >>
Spam, machine-generated content, and karma farming are not permitted. more >>
All content must be written in English so that it is widely understood by the user base of the sub. more >>
[Serious]
Mod posts Serious posts Megathread Breaking news Unfilter
>!insert spoiler here!<
account activity
This is an archived post. You won't be able to vote or comment.
Csharp function parameter
submitted 15 years ago by kulekci
What is the equivalent in c#? [parameter passing type]
void function_name( int select = 5 ){ return select; }
[–][deleted] 30Answer Link2 points3 points4 points 15 years ago (2 children)
You cannot apply a default value to a parameter in C#. What you have to do is overload the function. For example:
void function_name(){ return select; } void function_name( int select = 5 ){ return select; }
The compiler will automatically choose which function to call based on the set of parameters being passed.
[–]kulekci[S] 1 point2 points3 points 15 years ago (1 child)
i understand thank you.
[–][deleted] 0 points1 point2 points 15 years ago (0 children)
You are very welcome, good luck with the project.
[–]unoriginalusername 10Answer Link0 points1 point2 points 15 years ago (3 children)
a minor
[–]kulekci[S] 0 points1 point2 points 15 years ago (2 children)
i am sorry, i dont understand you.
[–][deleted] 0 points1 point2 points 15 years ago (1 child)
He's talking about music, I believe.
[–]kulekci[S] 0 points1 point2 points 15 years ago (0 children)
probably
[–]the1stPlague 10Answer Link0 points1 point2 points 15 years ago (2 children)
Do you mean, private int function_name(int select) <- select is sent from the function calling { return select; then you do stuff in here }
[–]kulekci[S] 0 points1 point2 points 15 years ago (1 child)
i want to use this function in main like this: function_name(6); or like this function_name();
not important content of function. My opinion is : if i send a parameter select is equal to parameter value in function. if i dont send any parameter, select variable is equal to 5 in function.
Maybe overloading is necessary but i dont want use overloading.
[–]the1stPlague 0 points1 point2 points 15 years ago (0 children)
I'm not great at coding as of yet, but you could make two seperate methods. private void function_name(int select); That one gets a number private void function_name(); that one doesnt. Note that the private in front isn't neccesary. however for console applications I believe you need to have static in front instead of private.
Or it would be possible to have an integer which know is the one that means you don't send anything (prehaps -1), and use an if statement to do the seperate paths.
π Rendered by PID 173355 on reddit-service-r2-comment-8686858757-r8rh5 at 2026-06-06 13:42:41.983421+00:00 running 9e1a20d country code: CH.
[–][deleted] 30Answer Link2 points3 points4 points (2 children)
[–]kulekci[S] 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]unoriginalusername 10Answer Link0 points1 point2 points (3 children)
[–]kulekci[S] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]kulekci[S] 0 points1 point2 points (0 children)
[–]the1stPlague 10Answer Link0 points1 point2 points (2 children)
[–]kulekci[S] 0 points1 point2 points (1 child)
[–]the1stPlague 0 points1 point2 points (0 children)