I'm making a console window app with C#, but how do I retrieve arguments when the app runs?
Printable View
I'm making a console window app with C#, but how do I retrieve arguments when the app runs?
By declaring array of string in the Main Method of your app . Like this :
Code:public static Main(string[] args)
{
'Your implementation here .
}
lol, now I have another problem.... When I use in a void an object from one of my references, I get this:
The type or namespace name 'xxxxx' could not be found (are you missing a using directive or an assembly reference?)
I've referenced it, and I've even used the Using statement. No difference. Help is greatly appreciated,
post the code
got that prob fixed, but alas, another question (three of em)
1. How do I clear the command window when developing a console app?
2. If there were no arguments passed, how an I figre that out?
3. If there was an argument passed, how do I parse it?
This has been posted here couple of times . Do a search . ;)Quote:
Originally posted by Danny J
1. How do I clear the command window when developing a console app?
If (arg==null)Quote:
2. If there were no arguments passed, how an I figre that out?
do this
You can handle the argument array as any other string array . Ex .Quote:
3. If there was an argument passed, how do I parse it?
foreach (string s in args)
{
s=s.remove(...,....)
Console.WriteLine(s);
}
You have other options like (storing them in arraylist , or hastable ...etc)
I'd suggest buying a book, alot of this will be answered.Quote:
Originally posted by Danny J
got that prob fixed, but alas, another question (three of em)
2. Check the size of the array
3. Depends on what kind of arguements you want your program to except.