Click here to Skip to main content
15,904,638 members
Home / Discussions / C#
   

C#

 
AnswerRe: Progrmming with USB in C# (Need a book) Pin
Christian Graus17-May-08 12:52
protectorChristian Graus17-May-08 12:52 
AnswerRe: Progrmming with USB in C# (Need a book) Pin
Giorgi Dalakishvili17-May-08 22:36
mentorGiorgi Dalakishvili17-May-08 22:36 
QuestionReportViewer Speed Pin
Amir Jalaly17-May-08 9:24
Amir Jalaly17-May-08 9:24 
QuestionTextRenderer.DrawText with TextFormatFlags.ModifyString Pin
Lea Hayes17-May-08 8:09
Lea Hayes17-May-08 8:09 
AnswerRe: TextRenderer.DrawText with TextFormatFlags.ModifyString Pin
Guffa17-May-08 11:37
Guffa17-May-08 11:37 
GeneralRe: TextRenderer.DrawText with TextFormatFlags.ModifyString Pin
Lea Hayes17-May-08 12:34
Lea Hayes17-May-08 12:34 
QuestionC# WebBrowser Pin
Member 428380717-May-08 7:32
Member 428380717-May-08 7:32 
AnswerRe: C# WebBrowser Pin
Ravi Bhavnani17-May-08 8:02
professionalRavi Bhavnani17-May-08 8:02 
QuestionHow connect forms with lines? Pin
Noemi Katinka17-May-08 6:43
Noemi Katinka17-May-08 6:43 
AnswerRe: How connect forms with lines? Pin
Anthony Mushrow17-May-08 6:53
professionalAnthony Mushrow17-May-08 6:53 
AnswerRe: How connect forms with lines? Pin
Thomas Stockwell18-May-08 3:56
professionalThomas Stockwell18-May-08 3:56 
Question[Message Deleted] Pin
pinna_hari17-May-08 4:55
pinna_hari17-May-08 4:55 
AnswerRe: String Problem [modified] Pin
PIEBALDconsult17-May-08 5:01
mvePIEBALDconsult17-May-08 5:01 
GeneralRe: String Problem Pin
pinna_hari18-May-08 23:15
pinna_hari18-May-08 23:15 
GeneralRe: String Problem Pin
DaveyM6918-May-08 23:33
professionalDaveyM6918-May-08 23:33 
AnswerRe: String Problem Pin
KennyPatel17-May-08 5:12
KennyPatel17-May-08 5:12 
AnswerRe: String Problem Pin
Ravi Bhavnani17-May-08 8:08
professionalRavi Bhavnani17-May-08 8:08 
QuestionWMI Help Pin
StevenWalsh17-May-08 4:48
StevenWalsh17-May-08 4:48 
AnswerRe: WMI Help Pin
Mircea Puiu17-May-08 21:15
Mircea Puiu17-May-08 21:15 
QuestionCorp a selection from Image? Pin
jamilkhan00717-May-08 4:47
jamilkhan00717-May-08 4:47 
AnswerRe: Corp a selection from Image? Pin
Anthony Mushrow17-May-08 7:03
professionalAnthony Mushrow17-May-08 7:03 
QuestionAddressbook from Outlook 2003 Pin
daniel9917-May-08 4:40
daniel9917-May-08 4:40 
Questionmy Dictionary removal code correct? Pin
George_George17-May-08 3:25
George_George17-May-08 3:25 
Hello everyone,


I want to iterator a Dictionary variable instance, and remove all elements under a specific condition.

Here is my code. My questions about whether the following solution will function correctly?

1. will dic.Remove(key) operation impact keys collection?
2. will dic.Remove(key) operation impact dic[key] operation?

I have such concern is because I heard while interation in the middle, remove any elements inside the Dictionary is dangerous because it will make some reference invalid and impact result. Any ideas?

Dictionary<string, Foo>.KeyCollection keys = dic.Keys;
foreach (string key in keys)
{
    // order is a public property of Foo class
    if (dic[key].order > 100)
    {
        // will keys collection variable be impacted if we remove here?
        // will dic[key] operation also be impacted?
        dic.Remove(key);
    }
}



thanks in advance,
George
AnswerRe: my Dictionary removal code correct? Pin
PIEBALDconsult17-May-08 4:09
mvePIEBALDconsult17-May-08 4:09 
GeneralRe: my Dictionary removal code correct? Pin
George_George17-May-08 4:14
George_George17-May-08 4:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.