我正在寻找这个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()
感谢您的帮助。
答案 0 :(得分: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()