what is command line argument? and how it can convert into string to numeric? how it accept number or string from user using command line argument?
Loading
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.
Master BillaPosted Aug 13, 2009, 4:04 AM
Could you point error my code?
thank you
Roei BarPosted Aug 13, 2009, 2:02 AM
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
if (args.Length > 0) // check agrs exists otherwise you might miss some others
{
int m = null;
int.TryParse(args[0],out m);
// this will take the first argument, if you need something fansier
// you will need to run in a for loop on all args array
}
}
}
}
if you liked this mark it as "Accepted Answer"
Master BillaPosted Aug 13, 2009, 12:29 AM
Command line args is send parameter or value from our side to your project to calculation or any other type implementation you will do in inside.
Sample code
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
if (args.Length = 1) // check agrs have none index zero length elements
{
int m = int.Parse(args[0]);
// then process here
}
}
}
}