c# main method ignores string variables -


I have been given a small # project to write, which basically has to wrap some DLS in the console application.

I have seen it as a strange problem. I have announced some local variables within the main method to use. The idea is that when the arguments are parsed, these values ​​are kept in these variables (the arguments are the main ones like -U: usernames).

Below is the code that I am using to start the process. .

  Nameshot ziptogo {public class ZipToGo {public static zero main (string [] args) {string user = null; Int divide = 0; String mysqlServer = null; String mysqlName = null; String mysqlUser = null; String mysqlPwd = null; String barcode = null; Boole zipped = false; Zipatogo zipong = new zip code (); If (args.Length == 0) {ziptogo.usage (); } // We see the debate and remove the values. For (int i = 0; i & lt; args.Length; i ++) {string [] value = ziptogo.getArgValue (args [i]); If (value [0]. Acquires ("- u") || Value [0]. Ecloss ("- u")) {user = value [1]; } If (value [0] .Equals ("- D")) value [0] .Equals ("- d")) {divisionid = Int32.Parse (value [1]); } ....  

As I am new to writing in C #, I am making clear that why strings like mysql server are being ignored by the main method ??

Integer dividing and string barcodes are only those variables that are not being ignored by the method.

Thank you.

To test it quickly, you can add this line after the main ():

  args = new string [] {"-u: user name"};  

Then take action by using the code step by using the debugger.

[edit] If getArgValue looks something like this:

  public string [] getArgValue (strings) {Return s.Split (':'); }  

So it should work for IMHO (quick and dirty, just walk).

[Edit:] A good solution is available for some command line parsing, which eliminates the need to add all those conditions, e.g.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -