Main method in c#
In this method static void Main(string[] args) what does the meaning of string[] args ? Where it is used in the program?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Posted Jun 12, 2012, 12:16 AM
For example, you're creating application, which needs to accepts the startup / console parameters then use call the application something like ,
consoleApplication.exe /name:murali /Site:www.c-sharpcorner.com
These values will be passed into the application using , string[] args parameter. It is not necessary to use the args when there is no startup / console parameter for an application.
using System;
class Hello
{
// static Main no return, arguments
public static void Main(string[] args)
{
for (int i = 0; i < args.Length; i++)
{
Console.Write("Args {0}, {1}", i, args[i]);
Console.Write("\n");
}
}
}
Hope this helps you.