-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (39 loc) · 1.25 KB
/
Program.cs
File metadata and controls
57 lines (39 loc) · 1.25 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
// See https://aka.ms/new-console-template for more information
// Console.WriteLine("Hello, World!");
using dotnet_test.Models;
using dotnet_test.Enums;
string[] names = { "Alice", "Bob", "Charlie" };
foreach (var item in names)
{
System.Console.WriteLine(item);
}
PaintType paintType = PaintType.HighSheen;
switch (paintType)
{
case PaintType.Basic:
System.Console.WriteLine("PaintType is basic");
break;
case PaintType.LowSheen:
System.Console.WriteLine("PaintType is LowSheen");
break;
case PaintType.HighSheen:
System.Console.WriteLine("PaintType is highSheen");
break;
default:
System.Console.WriteLine("PaintType is N/A");
break;
}
// 新对象 创建一个实体
// new PaintProduct() 是一个完整的实体/实例/对象
// 创建对象
PaintProduct paintProduct = new PaintProduct(19.99m,"Bob",paintType);
//给对象内的变量赋值
//读取对象
paintProduct.PrintPaintInfo();
User user = new AdminUser(2);
user.SetUserInfo("Bob",18);
user.DisplayUserInfo();
// 父类 user, 子类1号是adminuser,子类2号是guestuser
//子类可以作为父类的继承者
User adminUser = new AdminUser(5);
User guestUser = new GuestUser(6);