Click here to Skip to main content
16,007,126 members
Home / Discussions / C#
   

C#

 
AnswerRe: Shortcut key with 2 Letters Pin
Dan Neely30-Apr-07 10:41
Dan Neely30-Apr-07 10:41 
GeneralRe: Shortcut key with 2 Letters Pin
Pedro Luz30-Apr-07 11:18
Pedro Luz30-Apr-07 11:18 
QuestionError 550: FTP Pin
btsrinath30-Apr-07 9:50
btsrinath30-Apr-07 9:50 
AnswerRe: Error 550: FTP Pin
althamda30-Apr-07 22:45
althamda30-Apr-07 22:45 
QuestionUnhandled Exception - And don't know why Pin
JMOdom30-Apr-07 9:31
JMOdom30-Apr-07 9:31 
AnswerRe: Unhandled Exception - And don't know why Pin
Tarakeshwar Reddy30-Apr-07 9:50
professionalTarakeshwar Reddy30-Apr-07 9:50 
AnswerRe: Unhandled Exception - And don't know why Pin
Rudolf Jan1-May-07 0:17
Rudolf Jan1-May-07 0:17 
QuestionUnhandled Exception - and don't know why. Pin
JMOdom30-Apr-07 9:25
JMOdom30-Apr-07 9:25 
Confused | :confused: I am getting a strange problem when I try to run a program for my C# class.

I need to input 10 numbers each into two arrays. Then I need to extract each of the numbers and their corresponding numbers in the second array. These two get added together and stored into the third array.

I can get my numbers into the two arrays. When I press Enter, I end up getting a message that there was an exception and it wants to e-mail it to Microsoft. Below is my code for displaying the results. At one time I could at least, get it to do a Console Write Line.

Can anyone see where I’m making my mistake? I am only looking to find out why it is giving me the error message, and trying to send it to Microsoft. Any help would be appreciated.

public static void DisplayNumbers(double anArray1, double anArray2, double anArray3)<br />
 {<br />
     string results = " "; <br />
     int counter = 0;<br />
<br />
     for (int x = 0; x < anArray3; x++)<br />
     {<br />
         anArray3 = anArray1 + anArray2;<br />
         Console.WriteLine();<br />
         Console.WriteLine("{0}\t" + "+" + "\t{1}\t" + "=" + "\t{2}", anArray1, anArray2, anArray3);<br />
         while (counter < 10)<br />
         {<br />
             counter++;<br />
             results += "{0}\t" + " + " + "\t{1}\t" + " = " + "\t{2}" + anArray1 + anArray2 + anArray3;<br />
         }<br />
         string caption = "Array Methods Illustrated";<br />
         string outputMsg = "Array Numbers Shown\n\n" + "First\t" + "Second\t" + "      " + "   Sum\n";<br />
         MessageBox.Show(outputMsg, caption);<br />
     }


I'm listing the error I'm recieving and I'm also showing what is on Line 18. D'Oh! | :doh:

"Unhandled Exception: System.IndexOutOfRangeException: Index was outside the
bounds of the array at Exer4Chpt7.Program.main<> in G:\Programs\Exer4Chpt7\
Exer4Chpt7\program.cs: Line 18"

Line 18: double[] anArray1 = new double[10];

Thanks again. Smile | :)
AnswerRe: Unhandled Exception - and don't know why. Pin
btsrinath30-Apr-07 9:45
btsrinath30-Apr-07 9:45 
QuestionBasic 3.0 to .Net 2005 Pin
MoreMakarand30-Apr-07 9:10
MoreMakarand30-Apr-07 9:10 
AnswerRe: Basic 3.0 to .Net 2005 Pin
Dave Kreskowiak30-Apr-07 10:13
mveDave Kreskowiak30-Apr-07 10:13 
GeneralRe: Basic 3.0 to .Net 2005 Pin
MoreMakarand1-May-07 2:59
MoreMakarand1-May-07 2:59 
QuestionLogging Class and Method where exception occurred. Pin
AnneThorne30-Apr-07 9:08
AnneThorne30-Apr-07 9:08 
AnswerRe: Logging Class and Method where exception occurred. [modified*2] Pin
Tarakeshwar Reddy30-Apr-07 10:01
professionalTarakeshwar Reddy30-Apr-07 10:01 
GeneralRe: Logging Class and Method where exception occurred. [modified*2] Pin
PIEBALDconsult3-May-07 9:39
mvePIEBALDconsult3-May-07 9:39 
AnswerRe: Logging Class and Method where exception occurred. Pin
PIEBALDconsult3-May-07 10:17
mvePIEBALDconsult3-May-07 10:17 
GeneralRe: Logging Class and Method where exception occurred. Pin
PIEBALDconsult3-May-07 11:39
mvePIEBALDconsult3-May-07 11:39 
QuestionTextBox Pin
hardsoft30-Apr-07 9:07
hardsoft30-Apr-07 9:07 
AnswerRe: TextBox Pin
MoustafaS30-Apr-07 9:21
MoustafaS30-Apr-07 9:21 
Questiondll Pin
netJP12L30-Apr-07 8:08
netJP12L30-Apr-07 8:08 
AnswerRe: dll Pin
Christian Graus30-Apr-07 12:04
protectorChristian Graus30-Apr-07 12:04 
QuestionDataGridView Pin
Mohammed Elkholy30-Apr-07 7:34
Mohammed Elkholy30-Apr-07 7:34 
QuestionCreating classes that use the web / app.config for initialization Pin
Tristan Rhodes30-Apr-07 6:24
Tristan Rhodes30-Apr-07 6:24 
AnswerRe: Creating classes that use the web / app.config for initialization Pin
Pete O'Hanlon30-Apr-07 9:07
mvePete O'Hanlon30-Apr-07 9:07 
GeneralRe: Creating classes that use the web / app.config for initialization Pin
Tristan Rhodes1-May-07 3:14
Tristan Rhodes1-May-07 3:14 

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.