我在以下代码行中收到了 的错误(其中一些): 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
更多推荐
无法隐式转换类型
发布评论