args in main
C#
11
Posts
4
Posters
0
Views
1
Watching
-
For example, how to do this: public static void Main(string[] args) { Application.Run(new Form1()); } public void do_it() { int i; for (i=0; i
-
For example, how to do this: public static void Main(string[] args) { Application.Run(new Form1()); } public void do_it() { int i; for (i=0; i
public static void Main(string[] args) { do_it(args); Application.Run(new Form1()); } public static void do_it(string[] args) { // use your args here }
-
Something like this mabey?
string[] mainArgs; public static void Main(string[] args) { mainArgs = args; Application.Run(new Form1()); } public void do_it() { int i; for (i=0; i textBox1.Text += mainArgs[i]; }
**static** string[] mainArgs;
-
public static void Main(string[] args) { do_it(args); Application.Run(new Form1()); } public static void do_it(string[] args) { // use your args here }
-
Both of these solutions dont work. It says: An object reference is required for the nonstatic field, method, or property 'WindowsApplication1.Form1.mainArgs' ...
what exactly are you trying to do?
-
what exactly are you trying to do?
-
[STAThread] public static void Main(string[] args) { Application.EnableVisualStyles(); Application.DoEvents(); Application.Run(new myForm(args)); } public class myForm : Form { public myForm(string[] args) { InitializeComponent(); if (args != null && args.Length > 0) { for (int i = 0; i < args.Length; i++) { this.txt.Text += args[i]; } } } // leave this method for the designer private myForm() { InitializeComponent(); } // // rest of code // }