Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Remove Column from DataTable if All column values are NULL
WhatsApp
Shantanu Puranik
May 04
2016
10.2
k
0
0
for
(
int
col = dataTable.Columns.Count - 1; col >= 0; col--)
{
bool
removeColumn =
true
;
foreach
(DataRow row
in
dataTable.Rows)
{
if
(!row.IsNull(col))
{
removeColumn =
false
;
break
;
}
}
if
(removeColumn) dataTable.Columns.RemoveAt(col);
}
Remove Column from DataTable
Remove null column
DataTable
Up Next
Remove Column from DataTable if All column values are NULL