C# doubt
-
Don't get it!?
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
-
Don't get it!?
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
-
Explain in your own words why you cannot pass additional arguments in a function after using the params keyword.
If it's not broken, fix it until it is
-
Because params is an array of undetermined length. If you write:
void Foo(params int[] ints)
and try to call it with:Foo(1, 2, 3, 4)
How would it know that you want 4 as a separate argument, if the method were defined like this:void Foo(params int[] oneThroughThree, int fourth)
OK, maybe it could use type information, but that leads to bottomless pits where the Wumpus will eat you. MarcImperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!
Nice try, but
void Foo(params int[] oneThroughThree, int fourth)
would need to be called like this:
Foo(new int[] {1,2,3},4);
would it not?
Software Zen:
delete this;
-
(buzzer "eehhnn") No, we're sorry, wrong answer! (we were looking for a question "which of these thumbs is on the DARK SIDE?") :suss:
I didn't know I was participating in a quiz - instead my response was intended to tell you that I don't understand your apparent criticism of my reponse to the OP. Care to elaborate?
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
-
Explain in your own words why you cannot pass additional arguments in a function after using the params keyword.
-
I didn't know I was participating in a quiz - instead my response was intended to tell you that I don't understand your apparent criticism of my reponse to the OP. Care to elaborate?
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
-
Explain in your own words why you cannot pass additional arguments in a function after using the params keyword.
-
Squay mmem os pippk* (* These are my own words but I don't see how anyone else will be able to understand them)
I was wondering who summoned our great lord Cthulhu!
Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.
Simplicity is prerequisite for reliability. — Edsger W. Dijkstra
Regards, Sander
-
Explain in your own words why you cannot pass additional arguments in a function after using the params keyword.
Because if you could you wouldn't have homework to do.
Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.
Simplicity is prerequisite for reliability. — Edsger W. Dijkstra
Regards, Sander
-
Explain in your own words why you cannot pass additional arguments in a function after using the params keyword.
Not sure how C# implement that, but I'm guessing it has to do with how the arguments are push onto a stack before a function address is invoked. Being that the stack doesn't have anything to manage what type each parameter are and the Parameter type can be any number of arguments, making it difficult to separate the actual arguments from the Parameter ones.