-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkod7_RefParam.cs
More file actions
35 lines (29 loc) · 815 Bytes
/
kod7_RefParam.cs
File metadata and controls
35 lines (29 loc) · 815 Bytes
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
using System.Diagnostics;
using System.Reflection.Metadata.Ecma335;
using System.Reflection.PortableExecutable;
namespace testing
{
internal class Program
{
/*Задача 6:Swap с ref
Напиши обобщённый метод void Swap<T>(ref T a, ref T b)
В Main поменяй два int и две string.*/
static void Swap<T>(ref T x, ref T y)
{
var temp = x;
x = y;
y = temp;
}
static void Main(string[] args)
{
int a = 1;
int b = 11;
string c = "Hello";
string d = "Hi";
Swap(ref a, ref b);
Console.WriteLine($"a = {a}, b = {b}");
Swap(ref c, ref d);
Console.WriteLine($"c = {c}, d = {d}");
}
}
}