【发布时间】:2021-10-16 07:11:20
【问题描述】:
这是我的代码,我是编程新手:我从早上开始就在尝试,但找不到解决方案,请更正我的代码并帮助我。谢谢。
other.ClientData.NumDay <== getting null here.
我收到此错误:
System.NullReferenceException: '对象引用未设置为对象的实例。'
assignment3.Booker.ClientData.get 返回 null。
public int CompareTo(Booker other)
{
if (this.ClientData.NumDay > other.ClientData.NumDay)
{
return 1;
}
else if (this.ClientData.NumDay < other.ClientData.NumDay)
{
return -1;
}
else
{
return 0;
}
}
List<Booker> appointment = new List<Booker>(8)
foreach (var val in appointment)
{
Console.WriteLine(val);
}
appointment.Sort();
foreach (var val in appointment)
{
Console.WriteLine(val);
}
【问题讨论】:
标签: c# .net icomparable