[Solved] How to perform the below mentioned task(vb.net)?


You haven’t converted it correctly. The VB code selects DataGridViewRows, the C# code selects ints. You want to take N rows. VB.NET supports Enumerable.Take directly in the LINQ query, C# does not support it. So i’d use method syntax in C#.

So this works as desired (don’t translate Dim with dynamic but var):

int takeRows = int.Parse(daysamaxminsmv.Text);
var rows = DataGridView2.Rows.Cast<DataGridViewRow>().Take(takeRows);

foreach (DataGridViewRow row in rows)
{
    // piece of code...
}

0

solved How to perform the below mentioned task(vb.net)?