문제

In my DataTable, I have columns which begin with #col_. How do I delete only these columns from the table and leave the rest ?

I only know this snippet is needed - table.Columns.RemoveAt(index);

도움이 되었습니까?

해결책

var colsToRemove= (from DataColumn x in table.Columns
                          where x.ColumnName.StartsWith("#col_")
                          select x.ColumnName);

while (colsToRemove.Any())
    table.Columns.Remove(colsToRemove.First());
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top