-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparams.cs
45 lines (40 loc) · 1.08 KB
/
params.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
namespace method_params
{
class Program
{
public static void Main(string[] args)
{
int i = 0;
//Passing by value
//Program.SimpleMethod(ref i);
// Console.WriteLine(i);
/* int tot = 0;
int prod = 0;
Calculate(10, 20, out tot, out prod);
Console.WriteLine("{0} {1}",tot,prod);*/
int[] numbers = new int[3];
numbers[0] = 101;
numbers[1] = 102;
numbers[2] = 103;
ParamsMethod(numbers);
}
public static void SimpleMethod(ref int j)
{
j = 101;
}
public static void Calculate(int FN,int SN, out int Sum,out int Product)
{
Sum = FN + SN;
Product = FN * SN;
}
public static void ParamsMethod(params int[] Numbers)
{
Console.WriteLine("There are {0] elements",Numbers.Length);
foreach (int i in Numbers)
{
Console.WriteLine(i);
}
}
}
}