+ 1

I wish someone can be holding a private classes with me,methods in c# is getting abit tough for me.

Need serious help.

24th Oct 2017, 6:34 PM
Ibrahim Ali Bello
Ibrahim Ali Bello - avatar
6 Answers
+ 1
1) You can send multiple parameters to a function For example if you want to create a function that makes the sum of two numbers you need to pass two arguments to a function that accepts two parameters, make the sum of them and return the value. 2) Optional parameters are parameters that aren't necessary for the function For example your sum function can make the sum of two or three numbers depending on of how many arguments you pass to it the third parameter has to have a default value, in this case 0 so that when you pass only two values it doesn't change the result 3) You can use named arguments when you don't remember the order of the parameters you specify the parameter name inside the call of the function Tell me if you need examples
8th Nov 2017, 4:43 PM
Signum
+ 1
What's your problem?
8th Nov 2017, 3:48 AM
Signum
+ 1
yes. I need examples
8th Nov 2017, 7:24 PM
Ibrahim Ali Bello
Ibrahim Ali Bello - avatar
+ 1
1) int arg1 = 3; int arg2 = 2; int argSum; int sum(int param1, int param2) { argSum = param1 + param2; Console.WriteLine(argSum.ToString()); } sum(arg1, arg2); 2) int arg1 = 3; int arg2 = 2; int arg3 = 4; int argSum; int sum(int param1, int param2, int param3 = 0) { argSum = param1 + param2 + param3; Console.WriteLine(argSum.ToString()); } sum(arg1, arg2); sum(arg1, arg2, arg3); 3) int arg1 = 3; int arg2 = 2; int argSum; int sum(int param1, int param2) { argSum = param1 + param2; Console.WriteLine(argSum.ToString()); } sum(param2: arg2, param1: arg1);
8th Nov 2017, 8:17 PM
Signum
+ 1
wow. thanks a lot.
8th Nov 2017, 8:50 PM
Ibrahim Ali Bello
Ibrahim Ali Bello - avatar
0
multiple parameters, optional and named arguments
8th Nov 2017, 4:09 PM
Ibrahim Ali Bello
Ibrahim Ali Bello - avatar