Solved

One More Question On Args

Posted on 2004-09-27
1
288 Views
Last Modified: 2010-04-15
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.  
0
Comment
Question by:fattumsdad
1 Comment
 
LVL 69

Accepted Solution

by:
Callandor earned 500 total points
ID: 12160712
> 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

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Greetings C# program 17 127
C# bracket error 3 36
ASP.NET - Why is accordion not working? 3 19
Coding for the first time 9 35
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question