© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
15 replies
Binto86

set default value of parameter to other parameter [Answered]

ok, i am aware that this is probably not possible, but can i set default value of parameter x to value of parameter y?
consider this example:
public void MyMethod(string x, string y=x)
{
  //some code
}
public void MyMethod(string x, string y=x)
{
  //some code
}

would this be possible?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Default struct with default value [Answered]
C#CC# / help
4y ago
✅ How to set enum default int value
C#CC# / help
3y ago
How to pass value to parameter that require IEnumable string [Answered]
C#CC# / help
4y ago