Why no "params" keyword, String.IndexOfAny?

  • Thread starter Thread starter Jon Shemitz
  • Start date Start date
J

Jon Shemitz

If the String.IndexOfAny method's "anyOf" character array parameter
was marked as "params", we could call it as

S.IndexOfAny('a', 'b', 'c')

instead of

S.IndexOfAny(new char[] {'a', 'b', 'c'})

Why do we have to use the clumsy form?
 
I believe that they have a policy that the most used parameters are placed
first, then additional parameters that refine the method are placed at the
end. If they chose to use "params" for the "anyOf" parameter, this whould
have to be placed at the end, due to how "params" work. The additional
parameters for the overloaded methods would then have to go at the beginning
of the parameter list.

Chris
 
Christopher said:
I believe that they have a policy that the most used parameters are placed
first, then additional parameters that refine the method are placed at the
end. If they chose to use "params" for the "anyOf" parameter, this whould
have to be placed at the end, due to how "params" work. The additional
parameters for the overloaded methods would then have to go at the beginning
of the parameter list.

Sensible ... but look at String.Split

public string[] Split(params char[]);
public string[] Split(char[], int);

The 'main' overload has a params char[], the 'secondary' overload just
has a plain char[].
 
Can't explain that one. Looks like every rule has an exception, even at
Microsoft.

Chris

Jon Shemitz said:
Christopher said:
I believe that they have a policy that the most used parameters are placed
first, then additional parameters that refine the method are placed at the
end. If they chose to use "params" for the "anyOf" parameter, this whould
have to be placed at the end, due to how "params" work. The additional
parameters for the overloaded methods would then have to go at the beginning
of the parameter list.

Sensible ... but look at String.Split

public string[] Split(params char[]);
public string[] Split(char[], int);

The 'main' overload has a params char[], the 'secondary' overload just
has a plain char[].
 
Back
Top