Tuesday 5 February 2019

Select certain columns of a data table using C#.

SELECT specific columns from DataTable using LINQ in C#

Description:

In this example we explain that how to select certain columns of data table in C#.or how to fetch some specific column from Data Table in C#.or how to get some column from select statement in Data Table using C#.

Here we have one Data Table in which it’s contain many columns but I want to just fetch or retrieve some specific column so to achieve this below is the code foe how to retrieve some specific columns form Data Table in C#.
Code:

string[] selectedColumns = new[] { "Name","City"};
 DataTable dt= new DataView(fromDataTable).ToTable(false, selectedColumns);

0 comments:

Post a Comment