Type: Posts; User: Jim_Auricman
Search took 0.01 seconds.
October 10th, 2015, 08:14 AM
Yes, you could pass the array size into the method as a value parameter.
Loop as long as i < the array length, not i<= array length.
To display the contents of the array, start with this line, then...
October 9th, 2015, 09:23 PM
I see several problems with your method. In your 'for' loop, you are exceeding the bounds of the array. You are looping until i <= Array.Length; When you start with i = 0, you should run as long as i...
October 1st, 2015, 10:34 PM
October 1st, 2015, 10:20 PM
Yes, exactly. Look at the example that I posted. The Main method declares the variables and passes them into the method that does something with them and returns them.
October 1st, 2015, 10:10 PM
Here is an example of a function (method) which uses reference Parameters:
static void Get_Numbers(ref double D1, ref double D2, ref bool Success)
// Practice of a function using...
October 1st, 2015, 09:50 PM
You could display the result within the method instead of returning the result, but by returning it, the method is more generic thus being more useful than only displaying it when you calculate it....
September 30th, 2015, 04:05 PM
The Math function is returning an integer, but you are not displaying it.
Try adding code to display the result in Main before Console.ReadKey();, something like this:
September 29th, 2015, 10:48 AM
I usually prefer 'while' loops that exit when a flag is set, indicating that certain conditions have been met. For example,
// do whatever needs to be done;
// When condition(s)...
September 28th, 2015, 03:56 PM
The function is: private void button1_Click(object sender, EventArgs e)
Outside the 'for' loop, add: label4.Text = "Value of i where there was a match, is ";
Then inside the place where "if (die1...
September 28th, 2015, 03:16 PM
You won't see the display until the function exits.
Using the debugger, I saw that the dies matched 16 times. Of course, each time the results may vary. If you execute label3.Text = ""; and...
September 20th, 2015, 01:10 PM
static void Main(string args)
TestIfElse(10);-----------------------------------------------------------Why do I need the (10) here is I am declaring what numbers I am comparing to n in my next...
September 20th, 2015, 12:50 PM
Yes, in Main 'n' isn't declared anywhere.
I think your instructor wanted you to put the logic that you have in Main into the method that you created.
September 20th, 2015, 12:45 PM
You will find that using methods instead of writing in-line code for everything you want to do is much easier to understand & follow, especially if someone else wrote the code and you are trying to...
September 20th, 2015, 12:26 PM
September 19th, 2015, 07:28 PM
"I do not understand how you can add a second Method to the same class? "
Take a look at the thread "Newb trying to learn C# / stuck".
The sample program I added to the thread has several methods...
September 18th, 2015, 03:18 PM
It would be good if you would forget about using 'goto' if you want to write good code.
I have rewritten your program to use functions instead of 'goto's.
April 23rd, 2015, 09:02 PM
Thanks, Arjay. I'll check into using a post build event, as that might be useful to do in some cases.
April 23rd, 2015, 12:36 PM
Thanks for your responses.
Each project has its own BIN directory. Using a Utility directory whose path is in the environment allows access more easily than specifying each project's BIN path when...
April 23rd, 2015, 09:44 AM
That's exactly what I do; The disadvantage is that when a new version of a Console application is made, the new version has to be re-copied to the utility folder.
"Utility folder that has a public...
April 23rd, 2015, 07:12 AM
The problem with using a shortcut to access a console application is that inputting parameters is problematic.
You can use Console.ReadLine() to input the parameters, but if you have 3 or 4...
April 22nd, 2015, 01:10 PM
I develop both Windows Forms and Console applications in C#.
The forms applications are easy to access by creating a shortcut on the desktop pointing to the executable file in one of the BIN...
July 17th, 2012, 03:17 PM
Coding standards were developed because frequently someone else will have to maintain your code, and having the code work will not necessarily make it understandable and maintainable. Using "break"...
July 16th, 2012, 08:20 PM
If you use the while statement as follows:
bool finished = false;
while ((!finished) && (!_backgroundWorker.CancellationPending))
//When the exit condition is met-
You just need 6 variables:
int con1 = rng.Next(0, 17);
int vo1 = rng.Next(0, 5);
int con2 = rng.Next(0, 17);
int vo2 = rng.Next(0,...
The code is doing what you told it to do in this statement:
Console.WriteLine(conlist[con] + volist[vo] + conlist[con] + volist[vo] + conlist[con] + volist[vo]);
since you are only using one index...
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!