如何将符号“?”转换为在 c# 中到 vb.net 中?
我正在尝试将 c# 代码转换为 vb.net,但在转换符号“?”时遇到困难从 C# 到 vb.net。这是我要转换的代码
public audit_trail Mapper(IDataReader rdr)
{
audit_trail audit_trail = new audit_trail();
audit_trail.Log_id = rdr["Log_id"] is DBNull ? 0 : (int)rdr["Log_id"];
audit_trail.Host = rdr["Host"] is DBNull ? string.Empty : (string)rdr["Host"];
return audit_trail;
}
如何转换符号“?”到vb.net?
我想转换
audit_trail.Host = rdr["Host"] is DBNull ? string.Empty : (string)rdr["Host"];
成类似的东西
if rdr["Host"] is DBNull.Value then
audit_trail.Host = string.Empty
else
audit_trail.Host = rdr["Host"]
end if
,但代码太长,代码行太多..你们有想法转换成短的吗?
I am trying to convert c# code to vb.net but I have difficulties in converting the sign "?" in c# to vb.net. here my code to convert
public audit_trail Mapper(IDataReader rdr)
{
audit_trail audit_trail = new audit_trail();
audit_trail.Log_id = rdr["Log_id"] is DBNull ? 0 : (int)rdr["Log_id"];
audit_trail.Host = rdr["Host"] is DBNull ? string.Empty : (string)rdr["Host"];
return audit_trail;
}
how to convert the sign "?" to vb.net??
I would like to convert
audit_trail.Host = rdr["Host"] is DBNull ? string.Empty : (string)rdr["Host"];
to something like
if rdr["Host"] is DBNull.Value then
audit_trail.Host = string.Empty
else
audit_trail.Host = rdr["Host"]
end if
but the code is too long, too many line of code.. do you guys have an idea to convert to the short one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
三元运算符的 Visual Basic 语法为
If([condition,] op1, op2)
。The visual basic syntax for the ternary operator is
If([condition,] op1, op2)
.