1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6
7 namespace 第六天_流程语句
8 {
9 class Program
10 {
11 static void Main(string[] args)
12 {
13 Random r = new Random(); //1.创建一个能产生随机数的对象
14 while (true)
15 {
16 int _numR = r.Next(1, 10); //2.让产生随机数的这个对象 调用方法来产生随机数 能取到1到不能取到10,左闭右开区间。
17 Console.WriteLine(_numR);
18 Console.ReadKey();
19 }
20 }
21 }
22 }
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6
7 namespace 第六天_流程语句
8 {
9 class Program
10 {
11 static void Main(string[] args)
12 {
13 Random r = new Random(); //1.创建一个能产生随机数的对象
14 while (true)
15 {
16 int _numR = r.Next(1, 7); //2.让产生随机数的这个对象 调用方法来产生随机数 能取到1到不能取到7,左闭右开区间。6种可能
17 Console.WriteLine("请输入您的名字:");
18 string _name = Console.ReadLine(); //伪代码,对下面操作无影响
19 switch (_numR)
20 {
21 case 1:
22 Console.WriteLine("你上辈子是个大臣");
23 break;
24 case 2:
25 Console.WriteLine("你上辈子是个诸侯");
26 break;
27 case 3:
28 Console.WriteLine("你上辈子是个农民");
29 break;
30 case 4:
31 Console.WriteLine("你上辈子是个王子");
32 break;
33 case 5:
34 Console.WriteLine("你上辈子是个公主");
35 break;
36 default:
37 Console.WriteLine("你上辈子是个侍女");
38 break;
39
40 }
41 Console.ReadKey();
42 }
43 }
44 }
45 }