How to remove a string from Dictionary<>
- by Ranjana
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