How to remove a string from Dictionary<>
Posted
by Ranjana
on Stack Overflow
See other posts from Stack Overflow
or by Ranjana
Published on 2010-06-09T10:43:02Z
Indexed on
2010/06/09
11:02 UTC
Read the original article
Hit count: 216
i have used dictionary to collect the array of values
i have value in DataTable .
How to compare the values get from DataTable, whether dictionary key contains the name in DataTable. if DataTable has not that value,then remove that key name from dictionary.
My code:
DataTable dtcolumnsname = clsServiceManager.Instnce.Get_ColumnNames(ClsUserInfo.UserName, strTableName);
Dictionary<string,string> FinalDicColumnVal = new Dictionary<string,string>();
foreach (KeyValuePair<string, string> item in ColumnValues)
{
if (dtcolumnsname.Columns.Contains(item.Key))
{
FinalDicColumnVal.Add(item.Key, item.Value);
}
}
but this if (dtcolumnsname.Columns.Contains(item.Key)) is not get values of each datarow items in datatable.how to compare the dt row values with dictionary key names
© Stack Overflow or respective owner