Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

question on basic code

$
0
0
I found this example on a site, loaded in VS and it just gives a blank black screen but sample says it has output. I was looking for something to explain what args is. Can someone explain what args is.
using System;

class Program
{
    static void Main(string[] args)
    {
	// The program control flow begins here.
	// ... Use a foreach loop.
	// ... Then use an equivalent for loop.
	foreach (string value in args)
	{
	    Console.WriteLine("foreach: {0}", value);
	}
	for (int i = 0; i < args.Length; i++)
	{
	    string value = args[i];
	    Console.WriteLine("for: {0}", value);
	}
	Console.ReadLine();
    }
}



Output is supposed to be:

foreach: Arg1
foreach: Arg2
foreach: Arg3
for: Arg1
for: Arg2
for: Arg3

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>