Sign in to follow this  
Followers 0
xarzu

c sharp string array

3 posts in this topic

In a main routine of a c sharp program, you have a string array like this:

public static int Main(string[] arguments)

Well, let's suppose I am mimicing this sort of function. Would this be the proper use of a string array?

string[] arguments;

arguments[0] = "C:\\Users\\All Users\\Apple\\Some File.msi";

arguments[1] = "C:\\Users\\All Users\\Apple\\Another FIle.msi";

I get a compile error

Compiler Error CS0165 right on the first line.

I guess this is not how to assign strings in C#. But I thought it was.

Edited by xarzu
0

Share this post


Link to post
Share on other sites
In a main routine of a c sharp program, you have a string array like this:

public static int Main(string[] arguments)

Well, let's suppose I am mimicing this sort of function. Would this be the proper use of a string array?

string[] arguments;

arguments[0] = "C:\\Users\\All Users\\Apple\\Some File.msi";

arguments[1] = "C:\\Users\\All Users\\Apple\\Another FIle.msi";

I get a compile error

Compiler Error CS0165 right on the first line.

I guess this is not how to assign strings in C#. But I thought it was.

string[] arguments; //declares the array, you need to initialise it before you can use it.

string[] arguments= new string[2]; //declares the array and initialises it to 2 items.

Now you can do arguments[0] and arguments[1].

Also, check out: http://msdn.microsoft.com/en-us/library/aa288453(VS.71).aspx

Ta

Dave

Edited by DaveShaw
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

MoDaCo is part of the MoDaCo.network, © Paul O'Brien 2002-2016. MoDaCo uses IntelliTxt technology.