Link to home
Start Free TrialLog in
Avatar of mawingpui
mawingpuiFlag for Hong Kong

asked on

Enumerable.Select

How to print only the digits from the ID field?
(without using basic substring and indexOf functions to check each ID)

            DataTable dt = new DataTable();
            dt.Columns.Add("ID", typeof(String));
            dt.Rows.Add("USB22345");
            dt.Rows.Add("USC33399");
            dt.Rows.Add("USD66777");

            var query = from c in dt.AsEnumerable()
            select c["ID"];

            foreach (string item in query)
                Console.WriteLine(item.Select(c => char.IsDigit(c)));

Open in new window

SOLUTION
Avatar of kris_per
kris_per

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial