-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRefOutParamprogram.cs
52 lines (43 loc) · 1.24 KB
/
RefOutParamprogram.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
46
47
48
49
50
51
52
using System;
namespace ConsoleApp3
{
class Program
{
//too aviod function overloading we use params keywords in functions
int fun(params int[] data)
{
int count = 0;
int sum = 0;
foreach (var i in data)
{
sum = sum + i;
count++;
}
Console.WriteLine($"No of parameters is {count} and sum of parameters is : {sum}");
return count;
}
static void RefAndOut(int x , ref int y, out int z)
{
x = 90;
y = 37;
z = 21;
x++;
y++;
z++;
}
static void Main(string[] args)
{
Console.WriteLine("Muhaamad saad :");
Program p1 = new Program();
p1.fun(23, 53, 12, 43, 87);
p1.fun();
int a=12;
int b = 20;
int c = 56;
Console.WriteLine($"Before Passing : a is {a} b is {b} and c is {c}");
RefAndOut(2,ref b,out c);
Console.WriteLine($"After Passing : a is {a} b is {b} and c is {c}");
Console.ReadLine();
}
}
}