Is there a way in C# to be able to refer to a a parameter by both an internal and external name (in Swift this is known as argument labels/parameters)?
What I mean is suppose I have the following:
public static class Sport
{
public static void Print(int id sportID)
{
Console.Out.WriteLine(sportID);
}
}
public static void main()
{
Sport.Print(id: 123);
}
Internally, I refer to the id as sportID, but externally, the parameter is known as id.
A little late to the game, but I was looking for something like this as well. It is not exactly what the OP is after, but I think it is close enough.
The parameter names that are set when you declare the methods can be called when calling the method.
Declaring the method:
static string[] Roster(int numberOfDaysOff, int daysOfStartOnDay) {
// Method logic with the set names
}
Calling the method:
Roster(numberOfDaysOff: daysOff,daysOfStartOnDay: startDay);
Hope this helps future readers :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With