Click here to Skip to main content
15,895,557 members
Home / Discussions / C#
   

C#

 
AnswerRe: Urgent: helpe in regular expressions [modified] Pin
musefan2-Sep-09 5:09
musefan2-Sep-09 5:09 
GeneralRe: Urgent: helpe in regular expressions Pin
sh.alamdari2-Sep-09 19:49
sh.alamdari2-Sep-09 19:49 
QuestionSorting String Using Radix Sort Pin
gamer11272-Sep-09 3:22
gamer11272-Sep-09 3:22 
AnswerRe: Sorting String Using Radix Sort Pin
PIEBALDconsult2-Sep-09 3:26
mvePIEBALDconsult2-Sep-09 3:26 
AnswerRe: Sorting String Using Radix Sort Pin
harold aptroot2-Sep-09 3:45
harold aptroot2-Sep-09 3:45 
GeneralRe: Sorting String Using Radix Sort Pin
gamer11272-Sep-09 4:37
gamer11272-Sep-09 4:37 
GeneralRe: Sorting String Using Radix Sort Pin
harold aptroot2-Sep-09 4:54
harold aptroot2-Sep-09 4:54 
AnswerRe: Sorting String Using Radix Sort Pin
gamer11272-Sep-09 5:55
gamer11272-Sep-09 5:55 
I'm still having a problem with my string sorting. I always get the IndexOutOfRange exception during runtime.

How will I solve that?

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

            using (StreamReader outputLastNames = new StreamReader("lastnames.txt"))
            {
                int[] b = new int[vehicleCountInt + 1]; ;

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

                    Console.WriteLine();
                }

            }

            int N = arrayOfLastNames.Length;
            int W = arrayOfLastNames[0].Length;
            string[] temp = new string[vehicleCountInt];

            for (int d = W - 1; d >= 0; d--)
            {
                int[] count = new int[vehicleCountInt];
                for (int i = 0; i < N; i++)
                {
                    count[arrayOfLastNames[i][d] + 1]++;//the part that causes the run-time error
                }
                for (int k = 1; k < 256; k++)
                {
                    count[k] += count[k - 1];
                }
                for (int i = 0; i < N; i++)
                {
                    temp[count[arrayOfLastNames[i][d]]++] = arrayOfLastNames[i];
                }
                for (int i = 0; i < N; i++)
                {
                    arrayOfLastNames[i] = temp[i];

                    Console.WriteLine("{0}", arrayOfLastNames[i]);
                }
            }
        }

GeneralRe: Sorting String Using Radix Sort Pin
harold aptroot2-Sep-09 6:36
harold aptroot2-Sep-09 6:36 
GeneralRe: Sorting String Using Radix Sort Pin
gamer11272-Sep-09 7:17
gamer11272-Sep-09 7:17 
GeneralRe: Sorting String Using Radix Sort Pin
harold aptroot2-Sep-09 9:29
harold aptroot2-Sep-09 9:29 
GeneralRe: Sorting String Using Radix Sort Pin
gamer11272-Sep-09 16:07
gamer11272-Sep-09 16:07 
GeneralRe: Sorting String Using Radix Sort Pin
harold aptroot3-Sep-09 0:31
harold aptroot3-Sep-09 0:31 
GeneralRe: Sorting String Using Radix Sort Pin
gamer11273-Sep-09 1:36
gamer11273-Sep-09 1:36 
Answer[Message Deleted] Pin
ghelhei2-Sep-09 23:13
ghelhei2-Sep-09 23:13 
GeneralRe: Sorting String Using Radix Sort Pin
ghelhei2-Sep-09 23:13
ghelhei2-Sep-09 23:13 
QuestionEnabling Event in Grid View [modified] Pin
D4u2-Sep-09 2:42
D4u2-Sep-09 2:42 
AnswerRe: Enabling Event in Grid View Pin
Richard MacCutchan2-Sep-09 5:34
mveRichard MacCutchan2-Sep-09 5:34 
Questionregarding patch development ?? Pin
Tridip Bhattacharjee2-Sep-09 0:21
professionalTridip Bhattacharjee2-Sep-09 0:21 
AnswerRe: regarding patch development ?? Pin
Christian Graus2-Sep-09 0:31
protectorChristian Graus2-Sep-09 0:31 
AnswerRe: regarding patch development ?? Pin
Nagy Vilmos2-Sep-09 1:40
professionalNagy Vilmos2-Sep-09 1:40 
AnswerRe: regarding patch development ?? Pin
Henry Minute2-Sep-09 2:25
Henry Minute2-Sep-09 2:25 
QuestionSplash Screen In C# ? :S Pin
Saad Shuja1-Sep-09 23:50
Saad Shuja1-Sep-09 23:50 
AnswerRe: Splash Screen In C# ? :S Pin
Programm3r2-Sep-09 0:07
Programm3r2-Sep-09 0:07 
AnswerRe: Splash Screen In C# ? :S Pin
stancrm2-Sep-09 0:33
stancrm2-Sep-09 0:33 

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.