Click here to Skip to main content
15,897,518 members
Home / Discussions / C#
   

C#

 
AnswerRe: Ping in Thread (C#) Pin
harold aptroot4-Sep-09 6:03
harold aptroot4-Sep-09 6:03 
QuestionHighlighting items in listbox when mouse moves over them Pin
Gary Strunk4-Sep-09 5:21
Gary Strunk4-Sep-09 5:21 
AnswerRe: Highlighting items in listbox when mouse moves over them Pin
Nuri Ismail4-Sep-09 5:50
Nuri Ismail4-Sep-09 5:50 
GeneralRe: Highlighting items in listbox when mouse moves over them Pin
Gary Strunk4-Sep-09 7:12
Gary Strunk4-Sep-09 7:12 
QuestionNeed Help with SortedList<tkey,tvalue> [modified] Pin
gamer11274-Sep-09 4:52
gamer11274-Sep-09 4:52 
AnswerRe: Need Help with SortedList<tkey,tvalue> Pin
Richard MacCutchan4-Sep-09 5:38
mveRichard MacCutchan4-Sep-09 5:38 
GeneralRe: Need Help with SortedList<tkey,tvalue> Pin
gamer11274-Sep-09 5:47
gamer11274-Sep-09 5:47 
AnswerRe: Need Help with SortedList<tkey,tvalue> Pin
Gideon Engelberth4-Sep-09 6:20
Gideon Engelberth4-Sep-09 6:20 
gamer1127 wrote:
sortedLastName.Add(keyVal, arrayOfLastNames[i]); //I'm having a run-time error here that throws the ArgumentException

if (!sortedLastName.ContainsKey(keyVal))
{
sortedLastName.Add(keyVal, arrayOfLastNames[i]);
}
else
{
sortedLastName.Remove(keyVal);
sortedLastName.Add(keyVal, arrayOfLastNames[i]);
}


You did it wrong, then you did it right. Why do you even have the line that is getting the error? You are doing the same thing with the next if block.

gamer1127 wrote:
Console.WriteLine("{0}", sortedLastName.Keys[i]);//And sometimes throws the exception ArgumentOutOfRange Exception


You are getting this error for the same reason you were getting the previous error. If you have a duplicate key, you will not have "i" items in the list. You need to check if that many keys exist before trying to write them out.

On an style note, it appears that you have several properties of items all stored in separate arrays, and a single array of a class (with FirstName, LastName, PlateNumber, Type, and Year properties) may be better. Also, there is no reason to pass the array by ref just to change the values in them. If you are passing the array by ref so you can change the length, I would suggest returning an array instead, since you do not seem to be using the data already in the arrays.
GeneralRe: Need Help with SortedList<tkey,tvalue> Pin
gamer11274-Sep-09 6:51
gamer11274-Sep-09 6:51 
GeneralRe: Need Help with SortedList<tkey,tvalue> Pin
gamer11274-Sep-09 7:26
gamer11274-Sep-09 7:26 
AnswerRe: Need Help with SortedList<tkey,tvalue> Pin
Luc Pattyn4-Sep-09 7:57
sitebuilderLuc Pattyn4-Sep-09 7:57 
GeneralRe: Need Help with SortedList<tkey,tvalue> Pin
gamer11274-Sep-09 8:22
gamer11274-Sep-09 8:22 
GeneralRe: Need Help with SortedList<tkey,tvalue> Pin
Luc Pattyn4-Sep-09 8:41
sitebuilderLuc Pattyn4-Sep-09 8:41 
QuestionMouse events not triggered Pin
Dean Geddes4-Sep-09 4:42
Dean Geddes4-Sep-09 4:42 
AnswerRe: Mouse events not triggered Pin
Henry Minute4-Sep-09 4:58
Henry Minute4-Sep-09 4:58 
QuestionRead file with hex characters Pin
khalidelmeknesi4-Sep-09 3:00
khalidelmeknesi4-Sep-09 3:00 
AnswerRe: Read file with hex characters Pin
musefan4-Sep-09 3:08
musefan4-Sep-09 3:08 
AnswerRe: Read file with hex characters Pin
Luc Pattyn4-Sep-09 3:55
sitebuilderLuc Pattyn4-Sep-09 3:55 
GeneralRe: Read file with hex characters Pin
khalidelmeknesi5-Sep-09 0:43
khalidelmeknesi5-Sep-09 0:43 
GeneralRe: Read file with hex characters Pin
Luc Pattyn5-Sep-09 1:01
sitebuilderLuc Pattyn5-Sep-09 1:01 
QuestionLatebinding a VB6 DLL in a C# Project (with an interface?) Pin
MatthysDT4-Sep-09 2:56
MatthysDT4-Sep-09 2:56 
AnswerRe: Latebinding a VB6 DLL in a C# Project (with an interface?) Pin
stancrm4-Sep-09 3:08
stancrm4-Sep-09 3:08 
RantRe: Latebinding a VB6 DLL in a C# Project (with an interface?) Pin
MatthysDT4-Sep-09 3:25
MatthysDT4-Sep-09 3:25 
AnswerRe: Latebinding a VB6 DLL in a C# Project (with an interface?) Pin
Pete O'Hanlon4-Sep-09 3:46
mvePete O'Hanlon4-Sep-09 3:46 
GeneralRe: Latebinding a VB6 DLL in a C# Project (with an interface?) Pin
MatthysDT22-Sep-09 1:57
MatthysDT22-Sep-09 1:57 

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.