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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Master BillaRank #2,229 · 630 reputationPosted Aug 12, 2009, 8:29 PM EDT
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
}
}
}
}
Roei BarRank #1,271 · 1.4K reputationPosted Aug 12, 2009, 10:02 PM EDT
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 BillaRank #2,229 · 630 reputationPosted Aug 13, 2009, 12:04 AM EDT
Could you point error my code?
thank you