Extracting a hyperlink from the command line

I'm new to c# and need a bit of guidance on something that I fear is very obvious (but haven't figured out).  I want to pass a hyperlink via the command line to a variable called strHyperlink.  I was thinking of something like this for the command line:

D:\Testbed\Sandbox.exe http://website.com

I have added the variable to the Form class
string strHyperlink = Environment.CommandLine;

Open in new window

However, when I try to view the switch using the following:

var result = MessageBox.Show(strHyperlink, "Test", MessageBoxButtons.OK, MessageBoxIcon.Information);

Open in new window

I get:

"D:\Testbed\Sandbox.exe http://website.com"

Can someone please let me know how to get the hyperlink (in the cleanest possible way).  Thank you.
Andy BrownDeveloperAsked:
Who is Participating?
Pawan KumarConnect With a Mentor Database ExpertCommented:
String[] args = Environment.GetCommandLineArgs();
args[1] --will have your hyperlink
AndyAinscowFreelance programmer / ConsultantCommented:
Dim arguments As String() = Environment.GetCommandLineArgs()
arguments(1) contains the hyperlink
Andy BrownDeveloperAuthor Commented:
Great stuff - thank you.
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

AndyAinscowFreelance programmer / ConsultantCommented:
duh, I gave you the vb version for some reason.
Note you also need to check that there are more than 1 arguments (the first one is the application iteself)
Pawan KumarDatabase ExpertCommented:
welcome happy to help.
Andy BrownDeveloperAuthor Commented:
Thank you both.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.