In Pascal, you can declare multiple function arguments as a single type:
procedure TMyClass.Foo(Bar1, Bar2, Bar3 : string; Bar4, Bar5, Bar6 : Integer);
I always enjoyed this because it prevented needless repetition of type declarations. I know in C#, you can declare multiple variables as a single type:
int foo, bar;
But that doesn't appear to work for C# function arguments:
// Compiler doesn't like this because it expects types for all three arguments
public void Foo(int bar1, bar2, bar3) { }
Does C# have a way to shorthand the declaration of multiple arguments with a single type, or is there some reason it's been rejected? I can't seem to find much information on it, I just keep finding information on multiple-type arguments, which is not what I'm looking for.
Bar1, Bar2, Bar3are related they should probably have their own type. If they are unrelated it seem weird to use the same type declaration.paramskeyword allowing a varying number of parameters to be passed at the call site:public void Foo(params int[] bar) { }or use tuples:public void Foo((int, int, int) foo, (string, string, string) bar) { }