jeremychan
jeremychan

Reputation: 4459

how do i declare a string with arguments parsed from commandline?

how do i declare a string with arguments inside?

suppose

string path = "C:\\Work\\6.70_Extensions\\"

and 6.70_Extensions is replaced by args parsed i tried this:

string path = ("C:\\Work\\{0}\\NightlyBuild\\", args[0]) ;

where args[0] is a string. I suppose my syntax is wrong somewhere

Upvotes: 1

Views: 90

Answers (2)

Kobi
Kobi

Reputation: 138007

You're looking for String.Format:

string path = String.Format("C:\\Work\\{0}\\NightlyBuild\\", args[0]);

or simple concatenation (after a null check, of cource):

string path = "C:\\Work\\" + args[0] + "\\NightlyBuild\\";

Upvotes: 2

manojlds
manojlds

Reputation: 301117

You should be using string.Format for that.

string path = string.Format("C:\\Work\\{0}\\NightlyBuild\\", args[0]) ;

Upvotes: 5

Related Questions