Click here to Skip to main content
15,898,035 members
Home / Discussions / C#
   

C#

 
Questioncheck MSN Messenger user online status (C#)? Pin
Jassim Rahma4-Sep-09 5:26
Jassim Rahma4-Sep-09 5:26 
AnswerRe: check MSN Messenger user online status (C#)? Pin
stancrm4-Sep-09 6:19
stancrm4-Sep-09 6:19 
QuestionPing in Thread (C#) Pin
Jassim Rahma4-Sep-09 5:25
Jassim Rahma4-Sep-09 5:25 
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 
Hi. I'm now using the SortedList<TKey, TValue> to sort the strings from the text file. Is it possible to have a single key as the basis for comparing each string? If yes, I want to know how i will prevent the key from duplicating. Can someone help me?

As of now this is what I accomplished:

public static void SortByLastName(ref string[] arrayOfLastNames, ref string[] arrayOfFirstNames, ref string[] arrayOfPlateNum, ref string[] arrayOfType, ref string[] arrayOfYear)
       {
           Console.Clear();

           int vehicleCountInt = 0;

           Console.WriteLine("SHOW DATABASE: SORTING BY LAST NAME\n");

           using (StreamReader countVehicle = new StreamReader("vehiclecount.txt"))
           {
               vehicleCountInt = Int32.Parse(countVehicle.ReadLine());

               countVehicle.Close();
           }

           SortedList<string, string> sortedLastName = new SortedList<string, string>(vehicleCountInt);

           using (StreamReader outputLastNames = new StreamReader("lastnames.txt"))
           {

               for (int i = 0; i < vehicleCountInt; i++)
               {
                   arrayOfLastNames[i] = outputLastNames.ReadLine();

                   string keyVal = arrayOfLastNames[i];

                   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]);
                   }

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


               outputLastNames.Close();
           }

       }


modified on Friday, September 4, 2009 11:47 AM

AnswerRe: Need Help with SortedList&lt;tkey,tvalue&gt; Pin
Richard MacCutchan4-Sep-09 5:38
mveRichard MacCutchan4-Sep-09 5:38 
GeneralRe: Need Help with SortedList&lt;tkey,tvalue&gt; Pin
gamer11274-Sep-09 5:47
gamer11274-Sep-09 5:47 
AnswerRe: Need Help with SortedList&lt;tkey,tvalue&gt; Pin
Gideon Engelberth4-Sep-09 6:20
Gideon Engelberth4-Sep-09 6:20 
GeneralRe: Need Help with SortedList&lt;tkey,tvalue&gt; Pin
gamer11274-Sep-09 6:51
gamer11274-Sep-09 6:51 
GeneralRe: Need Help with SortedList&lt;tkey,tvalue&gt; Pin
gamer11274-Sep-09 7:26
gamer11274-Sep-09 7:26 
AnswerRe: Need Help with SortedList&lt;tkey,tvalue&gt; Pin
Luc Pattyn4-Sep-09 7:57
sitebuilderLuc Pattyn4-Sep-09 7:57 
GeneralRe: Need Help with SortedList&lt;tkey,tvalue&gt; Pin
gamer11274-Sep-09 8:22
gamer11274-Sep-09 8:22 
GeneralRe: Need Help with SortedList&lt;tkey,tvalue&gt; 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 

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.