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

[ad_1]

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

[ad_2]

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