How to delete a Dictionary row that is a Double by using an Int?
Posted
by Richard Reddy
on Stack Overflow
See other posts from Stack Overflow
or by Richard Reddy
Published on 2010-04-16T12:08:01Z
Indexed on
2010/04/16
12:13 UTC
Read the original article
Hit count: 177
Hi,
I have a Dictionary object that is formed using a double as its key values. It looks like this:
Dictionary<double, ClassName> VariableName = new Dictionary<double, ClassName>();
For my project I have to have the key as the double as I require values like 1.1,1.2,2.1,2.2,etc in my system.
Everything in my system works great except when I want to delete all the keys in a group eg all the 1 values would be 1.1,1.2, etc.
I can delete rows if I know the full value of the key eg 1.1 but in my system I will only know the whole number.
I tried to do the following but get an error:
DictionaryVariable.Remove(j => Convert.ToInt16(j.Key) == rowToEdit).OrderByDescending(j => j.Key);
Is there anyway to remove all rows per int value by converting the key?
Thanks, Rich
© Stack Overflow or respective owner