-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathstmts.cs
More file actions
110 lines (99 loc) · 1.83 KB
/
stmts.cs
File metadata and controls
110 lines (99 loc) · 1.83 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using System;
public class test_stmts
{
public static int ifStmt(int x)
{
if (x == 5)
return 0;
else
return 1;
}
public static void whileStmt(int x)
{
int i = 0;
while (i < 10)
{
x = x + 1;
}
}
public static int switchStmt()
{
object caseSwitch = new object();
int select = 0;
switch (caseSwitch)
{
case -1:
goto case true;
case 0:
goto case "123";
case "123":
select = 100;
break;
case true:
select = 101;
goto default;
default:
return select;
}
return 0;
}
public static void tryCatchFinally()
{
int x = 5;
try
{
if (x != 0)
throw (new System.Exception());
x = 0;
}
catch(System.Exception ex)
{
x = 1;
}
catch
{
throw;
}
finally
{
x = 2;
}
}
public static void forStmt()
{
int x = 0;
for (int i = 0, j = 10; i < j; i++, j--)
{
x = x - 1;
}
int a, b = 10;
for (a = 0; a < b; )
{
a++;
}
for( ; ; )
{
}
}
public static void doWhile()
{
int x = 0;
do
{
x = x + 1;
}
while (x < 10);
}
public static void checkedUnchecked()
{
int num = Int32.MaxValue;
unchecked
{
num = num + 1;
}
checked
{
num = num + 1;
}
}
}