且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

返回表示当前系统对象错误的Stystem.String方法ToString的重载不带1个参数

更新时间:2023-02-14 18:34:19

dt.Rows [0] [GraceTime]返回Object类型的变量。要使用格式化参数启用ToString(),您必须将其转换为DateTime ...

dt.Rows[0]["GraceTime"] returns a variable of Object type. To enable ToString() with formatting parameter you have to convert it to DateTime...
txtGrace.Text = Convert.ToDateTime(dt.Rows[0]["GraceTime"]).ToString("hh:mm tt" );