How do I read console application parameters?

Category: Introduction, viewed: 3305 time(s).

This example display how to pass some parameters as the application arguments, reads it and use it in our console application. The parameters passed to the application as an array of string. When no parameter passed the array length will be zero.

using System;

namespace Kodecsharp.Example.Intro
{
    public class CommandLineParameter
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Argument size: " + args.Length);
            for (int i = 0; i < args.Length; i++)
            {
                Console.WriteLine("Argument[" + i + "] : " + args[i]);
            }
        }
    }
}
Download Hundreds of Complimentary Industry Resources

Get hundreds of popular Industry magazines, white papers, webinars, podcasts, and more; all available at no cost to you. With more than 600 complimentary offers, you'll find plenty of titles to suit your professional interests and needs. Click Here and Sign up today!

Our Friends

Network Sites

Statistics

Locations of visitors to this page