Commandline Program in C#
using System;
class CommandLine
{
public static void Main(String []args)
{
String str="null";
int num=0;
if(args.Length!=0)
{
try
{
str=args[0];
num=int.Parse(args[1]);
Console.WriteLine("Arguments are : ");
}
catch(Exception e)
{
Console.WriteLine("Invalid Arguments : Error");
}
}
else
{
Console.WriteLine("No arguments passed : ");
}
Console.WriteLine(str);
Console.WriteLine(num);
}
}
No comments:
Post a Comment