Yes, that's it! Thanks for your effort! My program was actually working fine and getting the correct args, but I forgot that I had to pass another argument to see the behavior I was expecting from my program... So it was misattention of mine...
Cheers! On Mon, Jun 27, 2011 at 9:48 AM, m4rc0v0nh4g3n <[email protected] > wrote: > This is, what works for me > > using System; > > namespace PassArgsOnLinux > { > class MainClass > { > public static void Main (string[] args) > { > // not neccessary needed: > // string[] myArgs=null; > // int a=0; > // > // if (args!=null) { > // a = args.GetLength(0); > // myArgs = new string[a]; > // for (int i = 0; i < a; i++) { > // myArgs[i]=args[i]; > // } > // } > > Console.WriteLine ("Hello World!"); > if (args!=null) { > Console.WriteLine ("You passed {0} args.", > args.GetLength(0)); > for (int i = 0; i < args.GetLength(0); i++) > { > Console.WriteLine("arg {0}: > {1}",i+1,args[i]); > } > } else { > Console.WriteLine ("You passed 0 args."); > } > > Console.ReadLine(); > } > } > } > > /********** Thats what my console says: ************* > * > * $ mono PassArgsOnLinux.exe -myarg > * Hello World! > * You passed 1 args. > * arg 1: -myarg > * > * $ mono PassArgsOnLinux.exe > * Hello World! > * You passed 0 args. > * > * $ mono PassArgsOnLinux.exe -myarg1 -myarg2 > * Hello World! > * You passed 2 args. > * arg 1: -myarg1arg 2: -myarg2 > *************************************************/ > > > -- > View this message in context: > http://mono.1490590.n4.nabble.com/How-to-run-program-with-arguments-tp3624788p3627639.html > Sent from the Mono - General mailing list archive at Nabble.com. > _______________________________________________ > Mono-list maillist - [email protected] > http://lists.ximian.com/mailman/listinfo/mono-list > -- Maurício "De que serve do labor a sina, se o elaborado ao nada se destina?" (Goethe)
_______________________________________________ Mono-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-list
