无法隐式转换类型

编程入门 行业动态 更新时间:2024-10-14 04:26:29
本文介绍了无法隐式转换类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在以下代码行中收到了 的错误(其中一些): retval [curRowNum] .BrokerName =(( curRow [" BrokerName"] == System.DBNull.Value)?SqlString.Null:(string)curRow [" BrokerName"]); retval [curRowNum] .BrokerGroupId =((curRow [" BrokerGroupId"] == System.DBNull.Value)?SqlInt32.Null:(int)curRow [" BrokerGroupId"]) ; 错误是(反过来): 不能隐式转换类型''System.Data.SqlTypes.SqlString'' ''string''" "不能隐式转换类型''System.Data.SqlTypes.SqlInt32''''int''" 所以我很好奇,它在哪里得到我的想法 *含蓄地转换类型?当它非常明显我*明确地*尝试转换它。我已经在Google上完成了一些搜索,但是无法提出具有适当答案的。我希望你能用 来告诉我发生了什么。 thnx, Christoph

I am getting an error (a few among many) for the following lines of code: retval[curRowNum].BrokerName = (( curRow["BrokerName"] == System.DBNull.Value ) ? SqlString.Null : (string)curRow["BrokerName"] ); retval[curRowNum].BrokerGroupId = (( curRow["BrokerGroupId"] == System.DBNull.Value ) ? SqlInt32.Null : (int)curRow["BrokerGroupId"] ); The errors are (in turn): "Cannot implicitly convert type ''System.Data.SqlTypes.SqlString'' to ''string''" "Cannot implicitly convert type ''System.Data.SqlTypes.SqlInt32'' to ''int''" So I''m curious, where is it getting the idea that I am *implicitly* tyring to convert the type? When it is very apparent that I am *explicitly* trying to convert it. I''ve done some searches on Google but couldn''t come up with an appropriate answer. I''m hoping you''ll be able to tell me what''s going on. thnx, Christoph

推荐答案

Christopher, BrokerName和BrokerId定义的数据类型有哪些? Telmo Sampaio " Christoph Boget" < JC ***** @ yahoo>在留言中写道 news:eb ************** @ TK2MSFTNGP09.phx.gbl ... Christopher, What are the defined data types of BrokerName and BrokerId? Telmo Sampaio "Christoph Boget" <jc*****@yahoo> wrote in message news:eb**************@TK2MSFTNGP09.phx.gbl... 我收到一个错误(以下几行代码之一)以下代码行: retval [curRowNum] .BrokerName =((curRow [" BrokerName"] == System.DBNull .Value)?SqlString.Null :( string)curRow [" BrokerName"]); retval [curRowNum] .BrokerGroupId =((curRow [" BrokerGroupId"] == System.DBNull.Value)?SqlInt32.Null:(int)curRow [" BrokerGroupId"]); 错误是(反过来): 不能隐式转换类型''System.Data.SqlTypes.SqlString''到''string''" "不能隐式转换类型''System.Data.SqlTypes.SqlInt32'''' int''" 所以我很好奇,它在哪里得到的想法是我* *隐式*转换类型?当它非常明显我*明确*试图转换它。我已经在Google上进行了一些搜索,但是无法提出适当的答案。我希望你能够告诉我发生了什么。 thnx, Christoph I am getting an error (a few among many) for the following lines of code: retval[curRowNum].BrokerName = (( curRow["BrokerName"] == System.DBNull.Value ) ? SqlString.Null : (string)curRow["BrokerName"] ); retval[curRowNum].BrokerGroupId = (( curRow["BrokerGroupId"] == System.DBNull.Value ) ? SqlInt32.Null : (int)curRow["BrokerGroupId"] ); The errors are (in turn): "Cannot implicitly convert type ''System.Data.SqlTypes.SqlString'' to ''string''" "Cannot implicitly convert type ''System.Data.SqlTypes.SqlInt32'' to ''int''" So I''m curious, where is it getting the idea that I am *implicitly* tyring to convert the type? When it is very apparent that I am *explicitly* trying to convert it. I''ve done some searches on Google but couldn''t come up with an appropriate answer. I''m hoping you''ll be able to tell me what''s going on. thnx, Christoph

Christoph Boget< jc ***** @ yahoo>写道: Christoph Boget <jc*****@yahoo> wrote: 我收到了以下代码行的错误(许多中的一些): retval [curRowNum] .BrokerName =((curRow [" BrokerName"] == System.DBNull.Value)?SqlString.Null:(string)curRow [" BrokerName"]); retval [curRowNum] .BrokerGroupId = ((curRow [" BrokerGroupId"] == System.DBNull.Value)?SqlInt32.Null:(int)curRow [" BrokerGroupId"]); 错误是( (反过来): 无法隐式转换类型''System.Data.SqlTypes.SqlString''到''字符串''" "无法隐式转换输入''System.Data.SqlTypes.SqlInt32''到''int''" 所以我很好奇,它在哪里得到我隐含的想法* tyring转换类型?当它非常明显我*明确*试图转换它。我已经在Google上进行了一些搜索,但是无法提出适当的答案。我希望你能够告诉我发生了什么。 I am getting an error (a few among many) for the following lines of code: retval[curRowNum].BrokerName = (( curRow["BrokerName"] == System.DBNull.Value ) ? SqlString.Null : (string)curRow["BrokerName"] ); retval[curRowNum].BrokerGroupId = (( curRow["BrokerGroupId"] == System.DBNull.Value ) ? SqlInt32.Null : (int)curRow["BrokerGroupId"] ); The errors are (in turn): "Cannot implicitly convert type ''System.Data.SqlTypes.SqlString'' to ''string''" "Cannot implicitly convert type ''System.Data.SqlTypes.SqlInt32'' to ''int''" So I''m curious, where is it getting the idea that I am *implicitly* tyring to convert the type? When it is very apparent that I am *explicitly* trying to convert it. I''ve done some searches on Google but couldn''t come up with an appropriate answer. I''m hoping you''ll be able to tell me what''s going on.

我怀疑BrokerName是一个字符串属性 - 在这种情况下,如果 条件为真,那就好像你在说: retval [curRowNum] .BrokerName = SqlString .Null; 你明确*转换的唯一内容是从object(目前为编译器知道的)到string / int。 - Jon Skeet - < sk *** @ pobox> www.pobox/~skeet 如果回复该群组,请不要给我发邮件

I suspect that BrokerName is a string property - in which case, if the condition is true, it''s as if you''re saying: retval[curRowNum].BrokerName = SqlString.Null; The only things you''re *explicitly* converting are from object (as far as the compiler knows) to string/int. -- Jon Skeet - <sk***@pobox> www.pobox/~skeet If replying to the group, please do not mail me too

> BrokerName和BrokerId的定义数据类型是什么? ''字符串''和''int'',具体来说。 Christoph > What are the defined data types of BrokerName and BrokerId? ''string'' and ''int'', respecitvely. Christoph

更多推荐

无法隐式转换类型

本文发布于:2023-07-14 10:15:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1104078.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:类型   隐式

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!