Jump to content


Photo

c sharp string array

- - - - -

  • Please log in to reply
2 replies to this topic

#1
xarzu

xarzu

    Newbie

  • Members
  • Pip
  • 5 posts
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, 14 January 2009 - 05:16 AM.

  • 0

#2
DaveShaw

DaveShaw

    Newbie

  • Members
  • Pip
  • 19 posts
  • Location:Huddersfield
  • Devices:HTC Kaiser

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.microsof...453(VS.71).aspx

Ta
Dave

Edited by DaveShaw, 16 January 2009 - 10:22 AM.

  • 0

#3
annliu

annliu

    Newbie

  • Members
  • Pip
  • 2 posts
Hi,there are many computer ebooks free download.

free ebook download

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users