【发布时间】:2021-01-22 17:36:59
【问题描述】:
我正在开发一个 Blazor 应用程序,并且我实现了一些具有继承的类。当我创建派生类对象时,它工作正常,我可以访问和设置它从基类继承的所有值,但是当我遇到断点并使用调试器检查对象时,它只显示位于派生类。
发生了什么事?
类:
public class Event {
public int Id { get; set; }
[Required]
public string Title { get; set; }
[Required]
public DateTime Start { get; set; }
[Required]
public DateTime End { get; set; }
}
public class Shift :Event{
//[Required]
public ShiftRepeat Repeat { get; set; }
//[Required]
public List<Break> Breaks { get; set; }
public Shift ShallowCopy() {
return (Shift)this.MemberwiseClone();
}
}
元素调试器正在检查
var n = new Shift() {
Id = 1,
Title = "Shift 1",
Start = new DateTime(2021, 1, 18, 8, 0, 0),
End = new DateTime(2021, 1, 18, 16, 0, 0),
Repeat = ShiftRepeat.Daily,
Breaks = new List<Break>() {
new Break() {
Id = 1,
Title = "Lunch",
Start = new DateTime(2021, 1, 18, 12, 0, 0),
End = new DateTime(2021, 1, 18, 12, 30, 0)
}
}
};
【问题讨论】:
-
请在您的问题中包含代码 as formatted text - not 作为截图。
-
我无法将调试器检查窗口显示为格式化文本。它必须是屏幕截图才能显示我所看到的。
-
好的。只是想确保你明白这一点。你说得对,我是在偷工减料。我为自己的防守道歉。
-
别担心,你改进了你的问题,一切都很好:)
-
您能否提供有关该应用程序的更多信息?您使用的是什么 .NET 版本?采用哪种托管模式?服务器还是 WASM?
标签: c# inheritance blazor visual-studio-debugging