Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将此c代码转换为vb.net?_C#_Vb.net_Datagridview - Fatal编程技术网

C# 如何将此c代码转换为vb.net?

C# 如何将此c代码转换为vb.net?,c#,vb.net,datagridview,C#,Vb.net,Datagridview,您好,我在网上找到了这段代码,它似乎满足了我的要求。但是它是用我不熟悉的c语言写的。有没有能把它转换成vb.net的多语言程序员?我非常感谢你所给予的任何帮助 foreach (DataGridViewColumn clm in grdView.Columns) { Bool FoundData = false; foreach (DataGridViewRow row in grdView.Rows) { if (row.Cells[clm.Index].Value.ToString

您好,我在网上找到了这段代码,它似乎满足了我的要求。但是它是用我不熟悉的c语言写的。有没有能把它转换成vb.net的多语言程序员?我非常感谢你所给予的任何帮助

foreach (DataGridViewColumn clm in grdView.Columns)
{
Bool FoundData = false;
foreach (DataGridViewRow row in grdView.Rows)
{
     if (row.Cells[clm.Index].Value.ToString() != string.Empty)
     {
         FoundData = true;
         break;
     }
}
if (!FoundData)
{
     grdView.Columns[clm.Index].Visible = false;
}
}
试试这个:

For Each clm As DataGridViewColumn In grdView.Columns
    Dim FoundData As Boolean = False
    For Each row As DataGridViewRow In grdView.Rows
        If row.Cells(clm.Index).Value.ToString() <> String.Empty Then
            FoundData = True
            Exit For
        End If
    Next
    If Not FoundData Then
        grdView.Columns(clm.Index).Visible = False
    End If
Next

你可以使用任何在线转换工具


试试这个工具。您可能会发现它对以后的转换很有帮助:

请尝试转换器:+1以获得简单的答案。Bool不是有效的VB.NET类型。你把转换看得太字面了。它也不是一个有效的C类型-垃圾输入垃圾输出。
 For Each clm As DataGridViewColumn In grdView.Columns
   Dim FoundData As Bool = false
 For Each row As DataGridViewRow In grdView.Rows
    If (row.Cells(clm.Index).Value.ToString <> string.Empty) Then
        FoundData = true
        Exit For
    End If
 Next
 If Not FoundData Then
    grdView.Columns(clm.Index).Visible = false
 End If
 Next