TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
djcskinner
NA
15
0
IndexOutOfRangeException problem with code
Mar 23 2005 7:32 PM
hi i have the follwoing code.... : : static int a = 0; static string fileLine = ""; static string[] fileLines = null; static int totalFileLength; static int loopLength; static int index2; : : public static void ParseFile(string FileName) { fileLines = FileReaderUtil.SplitFileByLine(FileName); totalFileLength = (fileLines.Length / 36); loopLength = (fileLines.Length / totalFileLength); newMethod(); } public static void newMethod() { do { for(index2 = a; index2 <= loopLength ; index2++) { fileLine = fileLines[index2].Trim(); if( fileLine.Length > 0 ) { pitch1 = fileLine.Substring(5, 1).Trim(); if (pitch1 == "O") { pitchTot++; } pitchArray[pitchNumb] = pitchTot; } } a += loopLength; loopLength+=loopLength; pitchNumb++; newMethod(); } while (index2 < (loopLength * totalFileLength)); printarray(); // goes off an prints out the pitchArray } so i want the file to be split into sections of 36 lines each, then to cycle through each set of these 36 lines until the end of the file is reached, incrementing the pitchTot integer if the charcter found is equal to "O", and then adding it to the pitchArray at index pitchNumb. if i take the do loop out and the call to newMethod() from newMethod() itself, i get the correct output for the zero index of the pitchArray, but then when i put it back in i get this error: Additional information: Index was outside the bounds of the array. so i dont know if this is easily solved (or if there id a much better way of doing it!) as i am just starting to learn programming, and so am after some help! any given would be greatly appreciated. thanks
Reply
Answers (
3
)
data Form Wizard
Hi how to resize the conrols for different resolution?