mickmouse13
November 9th, 2009, 07:19 PM
this is a sample i got from some sight you type
./hello.exe A B C D the letters can be anything. and then this says helloworld,tells the number of letters, and then shows you the letters. What i get is HOW does it print {0} in line 10 if it has not been defined yet? The only thing i can see is that it runs through and kinda copy and pastes it to like ten from line 13... but why would it be done that way? im new but it seems like it would be better to do all the math and what ever and then use the WriteLine commands.. I hope i have been clear if anyone can explain these couple of lines it would be nice.
// Hello3.cs
// arguments: A B C D
using System;
public class Hello3
{
public static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
Console.WriteLine("You entered the following {0} command line arguments:",
args.Length );
for (int i=0; i < args.Length; i++)
{
Console.WriteLine("{0}", args[i]);
}
}
}
so the outcome is like this.
Hello, World!
You entered the following 4 command line arguments:
A
B
C
D
./hello.exe A B C D the letters can be anything. and then this says helloworld,tells the number of letters, and then shows you the letters. What i get is HOW does it print {0} in line 10 if it has not been defined yet? The only thing i can see is that it runs through and kinda copy and pastes it to like ten from line 13... but why would it be done that way? im new but it seems like it would be better to do all the math and what ever and then use the WriteLine commands.. I hope i have been clear if anyone can explain these couple of lines it would be nice.
// Hello3.cs
// arguments: A B C D
using System;
public class Hello3
{
public static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
Console.WriteLine("You entered the following {0} command line arguments:",
args.Length );
for (int i=0; i < args.Length; i++)
{
Console.WriteLine("{0}", args[i]);
}
}
}
so the outcome is like this.
Hello, World!
You entered the following 4 command line arguments:
A
B
C
D