I have:
public static int[] ArrayWorkings()
I can call it happily with MyClass.ArrayWorkings() from anywhere. But I want to build in some extra functionality by requiring a parameter such as:
public static int[] ArrayWorkings(int variable)
I get the error No overload for method ArrayWorkings, takes 0 arguments. Why is this?
You changed the function to require one parameter... so now all of your old function calls, which passed no parameters, are invalid.
Is this parameter absolutely necessary, or is it a default value? if it is a default then use a default parameter or an overload:
//`variable` will be 0 if called with no parameters
public static int[] ArrayWorkings(int variable=0)
// pre-C# 4.0
public static int[] ArrayWorkings()
{
ArrayWorkings(0);
}
public static int[] ArrayWorkings(int variable)
{
// do stuff
}
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