I am working on a legacy project which was developed using .NET Framework 2.0.
In this project, I get distinct values from DataRowCollection
by ItemNo
column. I am only interested in ItemNo
. The DataRow
consist of ItemNo
, Qty
and Date
.
I am thinking of iterating the DataRowCollection
and adding the unique ItemNo
into a list of string as below (not tested)
var items = new List<string>();
foreach (DataRow orderItem in rows)
{
var itemNo = orderItem["ITEMNO"].ToString().Trim();
if(items.Find(delegate(string str) { return str == itemNo ;}) == null)
{
items.Add(itemNo);
}
}
Is there a better way of doing this without LINQ (.Net Framework 2.0 doesnt like LINQ)