Hi, I am trying to pass parameters to my program, but I can't seam to get it to pass specific parameters. I want it like "C:\Age of Empires III Launcher.exe /x=agex.exe /y=agey.exe /z=age.exe" .

How would I go about doing that? I can't find a good tutorial on it. Thanks.

You could use those methods for printing an argument, but I want to use a specific argument.

For example, I want to look to see if the value of x is declared in the parameter. I don't care about the rest, I just want to get what the user put after /x= . Thanks.

Just for the fun of it: (this is perhaps your own tutorial!)
Start up a Console application and add the following in main:

for(int i = 0; i < args.Length; i++)
{
    Console.WriteLine("Argument {0} = {1}",  i, args[i]);
}
Console.ReadKey();

Raskahil laid the bottom but perhaps you needed one more hint?

You could use those methods for printing an argument, but I want to use a specific argument.

For example, I want to look to see if the value of x is declared in the parameter. I don't care about the rest, I just want to get what the user put after /x= . Thanks.

So you have an array of strings and you want to see if one of them looks like "/x=something".

To do that, you could loop through the strings and find one that begins with "/x=". You could use FirstOrDefault which does the looping for you:

string xArg = args.FirstOrDefault(s => s.StartsWith("/x="));

and then take xArg and sift it apart as you like. If you need any more help with string manipulation functions or array manipulation functions, say so, but the documentation should give you the tools you need.

You should google "C# GETOPT" and "C# GETOPTS", those will return robust solutions for handling parameters in your C# applications.

I have came to the conclusion that I will learn C# from a book, with tutorials that go along with the book. This is just too confusing for me. Thank you anyway.

BTW, I got GetOpt working I guess, but I don't know how to use it. The page on their site just tells you how to get it set up.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.