社区
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();这个错误怎么修复呀
...全文
2175
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)
无法
将
类型
string
隐式
转换
为system.
datetime
_菜鸟前端的咸鱼之旅-第八天:
类型
转换
-装箱,拆箱...
博客介绍了JS数据
类型
,包括原始
类型
和对象
类型
。阐述了装箱
转换
,即把基本
类型
转换
为对应对象,还说明了利用call方法或Object函数实现装箱。同时介绍了拆箱
转换
,也就是对象
类型
到原始
类型
的
转换
,涉及toPrimitive方法及不同参数下的
转换
规则,ES6后还可覆盖原有行为。
数据
类型
转换
本文详细介绍了如何在C#中处理
DateTime
类型
到字符串的
转换
,避免了常见的
类型
转换
错误
。通过具体代码示例,展示了如何在类中实现
DateTime
类型
到特定格式字符串的
转换
,并在查询操作中正确使用
转换
后的数据。
invalid cast from system.
string
to system.nullable
转换
可空
类型
报错
本文探讨了在C#中使用ChangeType方法
转换
Nullable
类型
时遇到的invalidcast
错误
,并提供了有效的解决策略,包括如何正确处理空值和非空值情况。
解决 "unable to convert MySQL date/time value to System.
DateTime
"
本文将详细说明在使用.NET(vb.net或c#.net)连接MySQL数据库时,遇到'
无法
将MySQL日期/时间值
转换
为System.
DateTime
'
错误
的解决方法。通过在连接字符串中添加特定参数,可以实现日期时间的有效
转换
。
C# 字符串(System.
String
)知识点总结
本文详细介绍了C#中字符串的操作,包括定义、是否为null、
转换
成各种
类型
(如int、decimal、
DateTime
)、字符串拼接、判断是否为空或null的方法、Sub
string
、Replace、Split、Join、大小写
转换
、Trim以及是否包含指定字符串的方法。文章通过实例演示了每种操作的用法,帮助开发者深入理解C#字符串处理。
C#
111,132
社区成员
642,541
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章