Real Funny.....................My teacher has discovered that i am overengineering my progress. It seems that I have been making things seem more complicated than they are. To solve this problem I have been assigned smaller projects so I can better understand how everything works. I will then start to combine what I have learned into bigger projects. For this project I am keeping it real simple. I am just using a for loop to print out the #'s 1 - 10. I am using a for loop because I know exactly what values I want returned. Here is the simple code:
namespace NumberLoop
{
class NumberLoop
{
static void Main(string[] args)
{
int n = 11;
int i = 0;
for (i = 1; i < n; i++)
Console.WriteLine("The Numbers in the Loop are: " + i);
}
}
}
Subscribe to:
Post Comments (Atom)
1 comment:
Very nice!
Also be aware that the i variable can be initialized right in the for loop like this:
for (int i = 1; i < max; i++) { /* more code */ }
Another thing I want to point out is that you initialized i to 0 and then immediately changed it to 1 in the init section of the for loop. If you need me to explain this further, let me know.
One last thing; realize that this is possible:
Console.WriteLine("i is now = {0}", i);
Where i will be placed into the string wherever you see "{0}". That's all. Simple.
Once again, good job!
Post a Comment