There is no overload for the method, takes 0 arguments?

I have:

public static int[] ArrayWorkings() 

I can call it happily with MyClass.ArrayWorkings () from anywhere. But I want to create additional functionality by requiring a parameter such as:

  public static int[] ArrayWorkings(int variable) 

I get the error No overload for the ArrayWorkings method, takes 0 arguments. Why is this?

+4
source share
1 answer

You changed the function to require one parameter ... so now all your old function calls that did not pass any parameters are invalid.

Is this option absolutely necessary, or is it the default value? if it is used by default, use the default option or 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 } 
+10
source

All Articles