0

我正在寻找将此 C# Linq 代码准确转换为 VB.net。我尝试了许多工具将 C# 转换为 VB,但没有一个 VB 转换的语句返回正确的结果。

C#

 var rows = GridView1.Rows.Cast<GridViewRow>().Where(a => a != row).ToList(); 

VB.net

 Dim rows = GridView1.Rows.Cast(Of GridViewRow)().Where(Function(a) a IsNot row).ToList()

该过程假设选择 Gridview 的行,不包括通过单击选择的行。所有行都返回,不排除任何行...

C#

Button btnUp = (Button)sender;
GridViewRow row = (GridViewRow)btnUp.NamingContainer;
 // Get all items except the one selected
var rows = GridView1.Rows.Cast<GridViewRow>().Where(a => a != row).ToList();

VB.net

Dim btnUp As Button = DirectCast(sender, Button)
Dim row As GridViewRow = DirectCast(btnUp.NamingContainer, GridViewRow)
' Get all items except the one selected
Dim rows = GridView1.Rows.Cast(Of GridViewRow)().Where(Function(a) a IsNot row).ToList()

感谢您的任何帮助。

4

1 回答 1

1

试试这个:

Dim btnUp As Button = DirectCast(sender, Button)
Dim row As GridViewRow = DirectCast(btnUp.NamingContainer, GridViewRow)
Dim rows = GridView1.Rows.Cast(Of GridViewRow)().Where(Function(a) a <> row).ToList()
于 2012-12-07T17:44:15.797 回答