One More Question On Args

I have the following code in a Windows Application:

static void Main(string[] args)
{
     if(args.Length > 0)
     {
          if(args[0].ToLower() == "-a")
          {
               Application.Run(new Form1());
          }
          else
          {
              Application.Run(new Form2());
          }
               
     }
}

If I put the "-a" in the command line (windowsapplication2.exe -a) it launches fine...  however, if I leave the "-a" off, the app won't launch.  Is there something wrong with me "else" statement.  
LVL 1
fattumsdadAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
CallandorConnect With a Mentor Commented:
> if(args.Length > 0)

If you don't give an argument, this condition will not be true, so try it with any argument other than "-a".
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.