Click here to Skip to main content
15,891,859 members
Home / Discussions / C#
   

C#

 
QuestionHow to create a sudoku like playfield Pin
tears.of.angels30-Apr-07 10:08
tears.of.angels30-Apr-07 10:08 
AnswerRe: How to create a sudoku like playfield Pin
Christian Graus30-Apr-07 12:02
protectorChristian Graus30-Apr-07 12:02 
QuestionShortcut key with 2 Letters Pin
Pedro Luz30-Apr-07 10:07
Pedro Luz30-Apr-07 10:07 
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 
Smile | :) 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 an array, and use 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 />
     }

This is what the exception looks like along with 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];

From what I've been taught in class I figure that this should work. Thanks again. Big Grin | :-D
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 
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 

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.