Tuesday, 31 March 2015

How to get Row Index using LINQ in C#?

In this post, Get the row index using LINQ in C# based on column

Ex :

  int rowindex = new System.Data.DataView(datatable).ToTable(false, new[] { "Columname" })
                .AsEnumerable()
                .Select(row => row.Field<string>("Columname")) .ToList()
                .FindIndex(col => col == variablewithvalue);


Happy Coding:)