-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNestedReturn.cs
More file actions
34 lines (28 loc) · 864 Bytes
/
Copy pathNestedReturn.cs
File metadata and controls
34 lines (28 loc) · 864 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
using System;
public static class Program {
public static CustomType ReturnArgument (CustomType arg) {
return arg;
}
public static CustomType ReturnIncrementedArgument (CustomType arg) {
++arg.Value;
return arg;
}
public static void Main (string[] args) {
var a = new CustomType(1);
CustomType b = ReturnArgument(ReturnIncrementedArgument(ReturnArgument(a)));
Console.WriteLine("a={0}, b={1}", a, b);
a.Value = 3;
Console.WriteLine("a={0}, b={1}", a, b);
b = ReturnArgument(ReturnArgument(a));
Console.WriteLine("a={0}, b={1}", a, b);
}
}
public struct CustomType {
public int Value;
public CustomType (int value) {
Value = value;
}
public override string ToString () {
return String.Format("{0}", Value);
}
}