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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get the Parameters

Status
Not open for further replies.

pasu

Programmer
Aug 9, 2003
17
US
I have an Accounting Application package running and the application can call another exe with the account code as parameter and pass it to the external program. My question is, how can my C# program read the parameter passed by my accounting application? Thanks!

Patrick
 
Not sure I follow what you mean, but are your apps Console or Window apps?

If the recieving app is a console app, then your Main function accepts an array of parameters, you just pass the parameters after the file name (ie. console.exe parm1 parm2).

Maybe if you can explain more of what the parameters are and how your apps are compiled we may be able to help you more.
 
There are two overloads of the static void Main method. One doesn't have any parameters, the other accepts an array of strings, which is what it sounds like you need.
Code:
public static void Main(string[] args)
{
   Console.WriteLine("Got " + args.Length.ToString() + " args in Main");
   Console.WriteLine("First arg is: " + args[0]);
}
Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
I am working on a windows application, and the accounting application will pass one parameter to my program. Can I do the same thing with the console application?

Patrick
 
public static void Main(string[] args) works in both console and windows apps.
 
Thank you very much, it works perfect!

Patrick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top