-
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?.
}
-
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!
-
Yes, that works.
Thanks
Similar Threads
-
By mako_123 in forum Java
Replies: 0
Last Post: 10-06-2007, 12:15 PM
-
By Matrix.net in forum .NET
Replies: 5
Last Post: 09-06-2006, 11:54 AM
-
By tomfluff in forum VB Classic
Replies: 7
Last Post: 07-18-2006, 04:22 PM
-
By INA_ctive in forum .NET
Replies: 2
Last Post: 06-22-2005, 11:38 PM
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks