Sponsored Ad

Thursday, March 31, 2011

How to Handle Console Application Arguments using C#

How to Handle Console Application Arguments using C#

This program helps beginners to get the arguments passed on command line in C# program. you can read these arguments from main method.

How to Handle Console Application Arguments using C#

using System;

namespace MyApp
{
    class console_arguments_class
    {
       public static void Main(string[] my_args)
        {
            Console.WriteLine("Number of Arguments: " + my_args.Length);
            for (int i = 0; i < my_args.Length; i++)
            {
                Console.WriteLine("Argument # " + i + ": " + my_args[i]);
            }

            Console.ReadLine();
        }
    }
}

No comments:

Post a Comment

Sponsored Ad

Development Updates