Click here to Skip to main content
15,905,776 members
Home / Discussions / C#
   

C#

 
Questionopen doc file in c# Pin
tanweer2-Sep-09 7:05
tanweer2-Sep-09 7:05 
AnswerRe: open doc file in c# Pin
Manas Bhardwaj2-Sep-09 9:14
professionalManas Bhardwaj2-Sep-09 9:14 
QuestionPrinter Pin
JollyMansArt2-Sep-09 5:47
JollyMansArt2-Sep-09 5:47 
AnswerRe: Printer Pin
Christian Graus2-Sep-09 11:24
protectorChristian Graus2-Sep-09 11:24 
QuestionReading and operating on information in excel (.XLS) files Pin
PtrN2-Sep-09 5:29
PtrN2-Sep-09 5:29 
AnswerRe: Reading and operating on information in excel (.XLS) files Pin
Keith Barrow2-Sep-09 5:35
professionalKeith Barrow2-Sep-09 5:35 
QuestionModify Form Size in code Pin
JollyMansArt2-Sep-09 5:10
JollyMansArt2-Sep-09 5:10 
AnswerRe: Modify Form Size in code Pin
DaveyM692-Sep-09 5:14
professionalDaveyM692-Sep-09 5:14 
AnswerRe: Modify Form Size in code Pin
musefan2-Sep-09 5:52
musefan2-Sep-09 5:52 
QuestionTracking Referral URL Pin
Abbas_here2-Sep-09 3:53
Abbas_here2-Sep-09 3:53 
AnswerRe: Tracking Referral URL Pin
Richard MacCutchan2-Sep-09 5:29
mveRichard MacCutchan2-Sep-09 5:29 
QuestionUrgent: helpe in regular expressions Pin
sh.alamdari2-Sep-09 3:52
sh.alamdari2-Sep-09 3:52 
AnswerRe: Urgent: helpe in regular expressions Pin
PIEBALDconsult2-Sep-09 4:07
mvePIEBALDconsult2-Sep-09 4:07 
GeneralRe: Urgent: helpe in regular expressions Pin
sh.alamdari2-Sep-09 20:07
sh.alamdari2-Sep-09 20:07 
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 

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.