C# 显示变量=。。。firstOrDefault作为字符串而不是typename

C# 显示变量=。。。firstOrDefault作为字符串而不是typename,c#,formatting,tostring,C#,Formatting,Tostring,如何格式化此变量以显示返回的日期 var lastDropStop = shipmentStatus.Stops.LastOrDefault(x => x.StopType.ToUpper() == "DROP"); debugFile.WriteLine("lastDropStop=" + lastDropStop.ToString()); 我看到的不是日期,而是类型名称: lastDropStop=MyComp.Outbound.Business.Entities.Models.Sh

如何格式化此变量以显示返回的日期

var lastDropStop = shipmentStatus.Stops.LastOrDefault(x => x.StopType.ToUpper() == "DROP");
debugFile.WriteLine("lastDropStop=" + lastDropStop.ToString());
我看到的不是日期,而是类型名称:

lastDropStop=MyComp.Outbound.Business.Entities.Models.ShipmentStatusStop

在打印对象时,也应该这样写属性名

debugFile.WriteLine("lastDropStop=" + lastDropStop.StopType.ToString()); // or lastDropStop.LastDropStop.ToString() or whatever the property name is

您是否只需要访问ShipmentStatusStop类型上的date属性<代码>调试文件.WriteLine(“lastDropStop=“+lastDropStop.WhateVerisDateProperty.ToString())没有对象定义很难知道。ToString()的默认行为是打印类型名。虽然您可以覆盖它,但这通常是不必要的。就像其他海报上说的那样,使用你想要印刷的合适的东西。是的,我完全以为我是在约会,而不是整个对象。