74 throw new ArgumentException("Obj cannot be null");
75 }
76 }
77 }
78 public class Comparer<T> where T : IComparable
79 {
80 public T GreaterThan(T d, T d2)
81 {
82 int ret = d.CompareTo(d2);
83 if (ret > 0)
84 {
85 return d;
86 }
87 else
88 {
89 return d2;
90 }
91 }
92
93 public T LessThan(T d, T d2)
94 {
95 int ret = d.CompareTo(d2);
96 if (ret < 0)
97 {
98 return d;
99 }
100 else
101 {
102 return d2;
103 }
104 }
105 }
106 }
复制代码
View Code 2.2、ExampleCore_3_1_7
1 namespace ExampleCore_3_1_7
2 {
3 internal class Program
4 {
5 static void Main(string[] args)
6 {
7 var person = new Person();
8 Console.ReadLine();
9 }
10 }
11 internal class Person
12 {
13 public int Age = 20;
14
15 public string Name = "jack";
16 }
17 }
复制代码
View Code 2.3、ExampleCore_3_1_8
1 namespace ExampleCore_3_1_8
2 {
3 internal class Program
4 {
5 static void Main(string[] args)
6 {
7 Console.WriteLine("Welcome to .NET Advanced Debugging!");
8
9 Person person = new Person() { Name = "PatrickLiu", Age = 32, HomeAddress = new Address() { Country = "China", Province = "冀州", City = "直隶总督府", Region = "广平大街23号", PostalCode = "213339" } };
7 AssemblyLoadContext: Default ALC - The managed instance of this context doesn't exist yet.
8 BaseSize: 0x18
9 ComponentSize: 0x4
10 DynamicStatics: false
11 ContainsPointers: false
12 Slots in VTable: 28
13 Number of IFaces in IFaceMap: 6
复制代码
2.2)、引用类型数组
编译项目,打开 Windbg,点击【文件】----》【launch executable】附加程序,打开调试器的界面,程序已经处于停止状态。我们利用【g】命令,继续运行程序,直到我们的控制台程序输出:Press any key to continue(Arrays),我们的调试器也处于卡住的状态。此时点击【break】按钮,就可以调试程序了。
由于我们手动停止调试器的实行,所以需要切换到托管线程的上下文中,实行命令【~0s】。