Making winforms application to accept command line arguments


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Making winforms application to accept command line arguments

  1. #1
    Join Date
    Jul 2006
    Posts
    91

    Making winforms application to accept command line arguments

    Hi All,

    In win forms thers a "main" method which does not accept any command line arguments.
    How can we make windows forms application to accept command line arguments passed to it?. Please refer me to a good resource if possible

    I tried the following in Win forms Application:-

    Intially the main function was empty (i.e. with no arguments)
    Then I did this:-

    Static void Main(string[] args)
    {
    MessageBox.Show(args[0].ToString);
    //the above line throws the following error messages:-
    1. The best overloadded method mach for MessageBox.Show(string) has some invalid arguments.
    2. Cannot convert from 'method group' to string.
    Can any one suggest me whts wrong with it. And how to get out of it to make win forms app to accept commandline arguments and display them?.

    }

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    When you call a method, such as ToString, you must include parentheses after the method name. If you change your code to:

    MessageBox.Show(args[0].ToString());

    it will run without error. The args array, however, already contains strings, so there's no need to call ToString. You may simply do this:

    MessageBox.Show(args[0]);

    Finally, if you want to run this code within Visual Studio, you must specify at least one command line argument. In Visual Studio's Solution Explorer, double-click Properties, then select the Debug tab and enter a value in the Command Line Arguments field.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Jul 2006
    Posts
    91
    Yes, that works.

    Thanks

Similar Threads

  1. Making a Filesharing LAN application
    By mako_123 in forum Java
    Replies: 0
    Last Post: 10-06-2007, 12:15 PM
  2. an application for making dll's ?
    By Matrix.net in forum .NET
    Replies: 5
    Last Post: 09-06-2006, 11:54 AM
  3. Making an Application from within an application.
    By tomfluff in forum VB Classic
    Replies: 7
    Last Post: 07-18-2006, 04:22 PM
  4. Replies: 2
    Last Post: 06-22-2005, 11:38 PM
  5. Career Advice
    By Troy Easterling in forum Careers
    Replies: 1
    Last Post: 12-29-2001, 07:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center