我如何...修复此错误VB到C#代码转换 [英] How do I...fix this error VB to C# code conversion

查看:87
本文介绍了我如何...修复此错误VB到C#代码转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



我在这里做VB到C#的一些代码转换但面对下面列出的一些错误

下面是我的VB代码< br $> b $ b



 如果 IsDBNull(rs。 Item(  raw))然后 
new_scale = True
sb.Append( < input type =hiddenname =new_scalevalue =1>

对于 x = 0 2 ' raw = 0到2
sb.Append( < tr id =row _& x& >
sb.Append( < td id =row _& x& _ col_0>









转换后是我的C#代码



< pre lang =xml> if(Information.IsDBNull(rs.Item(raw)))
{
new_scale = true;
sb.Append(< input type = \ hidden \ name = \ new_scale \ value = \ 1 \ > );

for(x = 0; x < = 2; x ++)

{

sb.Append(< tr id = \ row _ + x + \ > );
sb.Append(< td id = \ row _ + x + _ col_0 \ > < /跨度>);

}
}











使用在线转换工具将上述VB代码转换为C#后发生以下错误:

if(Information.IsDBNull(rs.Item(raw)) ):



当前情况下不存在信息这个名称。

任何人都可以帮我修理它

解决方案

您可以随时自动翻译代码(而非转换!)。请看我过去的答案:

代码解释,C#到VB.NET [ ^ ]。



最可靠,最优质的方法是使用开源的ILSpy。



Maciej Los在你对上一个问题的评论中得到了很好的建议:停止这样做!请遵循这个建议。

此外,停止重新发布相同的问题;这被视为滥用。



-SA


阅读本文:https :?//social.msdn.microsoft.com/Forums/vstudio/en-US/6199433a-a0f6-41e3-a482-d608ef89cf85/what-is-cs-equivalent-for-vbs-isdbnull论坛= netfxbcl [ ^ ]


  //  尝试使用if(Convert.IsDBNull(fieldValues [fieldCounter])) 
/ / 获取数据,用NA替换缺失值并显示它。
while (dr.Read())
{
d r.GetValues(fieldValues);

for int fieldCounter = 0 ; fieldCounter& lt; fieldCount; fieldCounter ++)
{
if (Convert.IsDBNull(fieldValues [fieldCounter]) )
fieldValues [fieldCounter] =& quot; NA& quot ;;
}
grid.Rows.Add(fieldValues);
}
dr.Close();


Hello

Am here doing VB to C# conversion of some code but face some error listed below
Below is my VB Code


If IsDBNull(rs.Item("raw")) Then
           new_scale = True
           sb.Append("<input type=""hidden"" name=""new_scale"" value=""1"">"

           For x = 0 To 2 ' raw = 0 To 2
               sb.Append("<tr id=""row_" & x & """>")
                   sb.Append("<td id=""row_" & x & "_col_0"">")





and it is my C# code after conversion

if (Information.IsDBNull(rs.Item("raw")))
        {
            new_scale = true;
            sb.Append("<input type=\"hidden\" name=\"new_scale\" value=\"1\">");

            for (x = 0; x <= 2; x++)

            {

                sb.Append("<tr id=\"row_" + x + "\">");
                sb.Append("<td id=\"row_" + x + "_col_0\">");

            }
}






After coversion the above VB code to C# using online conversion tool following error occur:
if (Information.IsDBNull(rs.Item("raw"))):

The name 'Information' does not exists in current context.
Anyone please help me to fix it

解决方案

You can always translate code (not "convert"!) automatically. Please see my past answer:
Code Interpretation, C# to VB.NET[^].

Most reliable and quality method is using open-source ILSpy.

You got a very good advice by Maciej Los in his comment to your previous question: stop doing it! Do follow this advice.
Also, stop re-posting the same question; this is considered as abuse.

—SA


Read this : https://social.msdn.microsoft.com/Forums/vstudio/en-US/6199433a-a0f6-41e3-a482-d608ef89cf85/what-is-cs-equivalent-for-vbs-isdbnull?forum=netfxbcl[^]


// Try using if (Convert.IsDBNull(fieldValues[fieldCounter]))
// Get data, replace missing values with "NA" and display it.
  while (dr.Read())
  {
     dr.GetValues(fieldValues);

     for (int fieldCounter = 0; fieldCounter &lt; fieldCount; fieldCounter++)
     {
        if (Convert.IsDBNull(fieldValues[fieldCounter]))
           fieldValues[fieldCounter] = &quot;NA&quot;;
     }
     grid.Rows.Add(fieldValues);
  }
  dr.Close();


这篇关于我如何...修复此错误VB到C#代码转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆