社区
C#
帖子详情
错误 1 无法将类型“string”隐式转换为“System.DateTime”
qq_33401683
2019-01-01 10:51:08
this.dateTimePicker1.Value = Convert.ToString(dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value).Trim();这个错误怎么修复呀
...全文
2109
22
打赏
收藏
错误 1 无法将类型“string”隐式转换为“System.DateTime”
this.dateTimePicker1.Value = Convert.ToString(dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value).Trim();这个错误怎么修复呀
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
22 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
PerDign
2019-01-09
打赏
举报
回复
DataTime.Parse( Convert.ToString(dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value).Trim() )
大鱼>
2019-01-09
打赏
举报
回复
DataTime.Parse
gishys
2019-01-07
打赏
举报
回复
需要类型转换
qq_44393202
2019-01-04
打赏
举报
回复
你两边类型不一样,string类型是不能隐式转换datetime类型,你可以用convert.todatetime()进行强制转换
lc011289
2019-01-04
打赏
举报
回复
左边时间控件的value是datetime类型的,右边是string类型的,强转一下试试
qq_33513833
2019-01-04
打赏
举报
回复
Convert.ToDateTime(dr["time"].ToString()).ToString("yyyy/MM/dd")
抢眼~
2019-01-03
打赏
举报
回复
DataTime.Parse( Convert.ToString(dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value).Trim() )
悟V-SpHeNIC
2019-01-03
打赏
举报
回复
将日期串转成datetime类型
xiaoxiangqing
2019-01-03
打赏
举报
回复
string要符合日期格式才可以转为System.DateTime
xiaoyu5425
2019-01-02
打赏
举报
回复
强转,用强的不行就打死它
天下无雪的马甲
2019-01-02
打赏
举报
回复
用显式转换吧,有没有DameTime()
gs0038
2019-01-02
打赏
举报
回复
this.dateTimePicker1.Value =DataTime.Parse( Convert.ToString(dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value).Trim() )
weixin_44363496
2019-01-02
打赏
举报
回复
两边类型,不一样
娃都会打酱油了
2019-01-02
打赏
举报
回复
这种提示都不会解决啊…… 除了obj可以接收任何数据类型,否则必须类型对应才能赋值
浪子fred
2019-01-02
打赏
举报
回复
判断String的格式,根据格式转换
很闲hx
2019-01-02
打赏
举报
回复
this.dateTimePicker1.Value = Convert.ToDateTime(dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value).Trim(); dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value 必须是yyyy-MM-dd hh:mm:ss
liusa1997
2019-01-01
打赏
举报
回复
convert.todatetime(Convert.ToString(dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value).Trim())
,本来就是string类型怎么可能直接赋值给datetime类型的
以专业开发人员为伍
2019-01-01
打赏
举报
回复
等号两边类型不兼容,根本不能赋值。这种语法错误,读代码时应该自己有意识吧。
xuzuning
2019-01-01
打赏
举报
回复
DataTime.Parse( Convert.ToString(dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value).Trim() )
关中山水郎
2019-01-01
打赏
举报
回复
我服,这种问题完全是最基础的
加载更多回复(2)
CS0029
无法
将
类型
“
string
”
隐式
转换
为“System.Windows.Forms.TextBox”
CS0029报错解决方法
如何解决”
无法
将
类型
为“System.
DateTime
”的对象强制
转换
为
类型
“System.
String
”。“...
字段Time在数据库中为
datetime
类型
dr.Get
String
(3).To
String
() dr.Get
String
(3).To
String
()=>dr.Get
DateTime
(3).To
String
("yyyy-MM-ddhh:mm:ss") dr.Get
String
(3).To
String
()=>dr.Get
DateTime
(3)....
无法
将 NULL
转换
成“System.
DateTime
”,因为它是一种值
类型
在C# 2.0里面的数据
类型
中,分为值
类型
和引用
类型
,引用
类型
可以初始化为null,可是值
类型
是不可以的。 比如经常用到的System.Guid
类型
,要么赋值为Guid.NewId,要么赋值为Guid.Empty。...
错误
1
无法
将 NU
問題排查:
类型
“System.
DateTime
”的对象
无法
转换
为
类型
“System.
String
”
當然還有其他同類提示,例如 int/decimal 無法轉 System.
String
等等 無獨有偶 這些錯誤幾乎都是在 DataTable 轉換成 IList 的時候發生的 上網搜索了一下,找到這個解決方式: 將原本的 pi.SetValue(t, v...
.net core Unable to cast object of type ‘System.DBNull‘ to type ‘System.
DateTime
‘.解决方案
重字面上来看,就是
类型
转换
错误
。 二,解决方案 像这类问题理所当然的就去找了模型中对应的
DateTime
类型
的属性。结果去数据库检查发现,该
类型
的都全部赋值,不应该报错呀。然后又仔细检查了一遍模型,还真发现端倪...
C#
111,119
社区成员
642,554
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章