Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

static void Main(string[] Args) 1

Status
Not open for further replies.

deulyd

Programmer
Oct 17, 2001
106
CA
Hi,

I am trying to pass the Args variable of the Main to another method in the class like that :

static void Main(string[] Args)
{
ParseArguments(Args);
}

private void ParseArguments(string[] aArgs)
{
MessageBox.Show("parse");
}

But I'm getting that error when compiling : "An object reference is required for the nonstatic field, method, or property."

How can I pass the Args to another method?

Thanks

Daniel
 
Notice that your Main method is static - which means there is no instance of your class created.

So inside your main method, create an instance of your class, and then call that method.


static void Main(string[] Args)
{
MyClass instance = new MyClass(); //This should be your class name
instance.ParseArguments(Args);
}

 
Thank you sooo much... I never realized that! :)

Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top