Filter condition not working properly on list (C#3.0)

Posted by Newbie on Stack Overflow See other posts from Stack Overflow or by Newbie
Published on 2010-05-07T02:46:31Z Indexed on 2010/05/07 2:58 UTC
Read the original article Hit count: 156

Filed under:

I have a datatable that has many NULL or " " strings. Next I am type casting the DataTable to a list . Now if I want to filter those conditions on this list and get the resultant value(without NULL or String.Empty or " " records) what should I do?

My code

DataTableExtensions.AsEnumerable(dt).ToList().ForEach(i =>
                {
                    if (i[0] != null)
                    {
                        if ((i[0].ToString() != string.Empty)|| (i[0].ToString() != " "))
                        {
                            list = dt.AsEnumerable().ToList();
                        }
                    }

                });

But I am getting all the records. It is not getting filtered.

Using C#3.0

Please help Thanks

© Stack Overflow or respective owner

Related posts about c#3.0