-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChapter9.cs
More file actions
40 lines (38 loc) · 1.19 KB
/
Chapter9.cs
File metadata and controls
40 lines (38 loc) · 1.19 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
using System;
using System.IO;
namespace Chapter9
{
class Program
{
public static void MainTest()
{
int x = 3;
while(x > 0)
{
Console.WriteLine("x : {0}", x);
--x;
}
Console.WriteLine("Out of loop");
Console.WriteLine("*************************************");
int y = 0;
do
Console.WriteLine("y is {0}", y++);
while(y < 3);
Console.WriteLine("*************************************");
/*
在C#中,不可以执行一个switch段中的代码然后直接执行接下来的部分
*/
Console.WriteLine("*************************************");
using(TextWriter tw = File.CreateText("Lincoln.txt"))
{
tw.WriteLine("Four score and seven years ago,...");
}
using(TextReader tr = File.OpenText("Lincoln.txt"))
{
string InputString;
while(null != (InputString = tr.ReadLine()))
Console.WriteLine(InputString);
}
}
}
}