How to fill a fixed length string

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Maybe this is a stupid question but I didn't find the answer.

I've to work with fixed length string:

string[] sName = new string[15];

the following instruction give back a compiler error:

sName="test";

"impossible to convert type string into string[]"

How can I set a string to string[] ?

Thank you in advance

Keven Corazza
 
you have defined sName as an array of strings, not an array of characters.

sName[0] = "test" is how you would put the string "test" in the first
position in the
string array you have defined.

if what you want is to create a unicode character array from a given string,
follow sample below.

string s = "test";
char[] sName = s.ToCharArray();

-Darren Shaffer
 
Yes, what big mistake!

Thank you.

Keven

Darren Shaffer said:
you have defined sName as an array of strings, not an array of characters.

sName[0] = "test" is how you would put the string "test" in the first
position in the
string array you have defined.

if what you want is to create a unicode character array from a given string,
follow sample below.

string s = "test";
char[] sName = s.ToCharArray();

-Darren Shaffer


Keven Corazza said:
Maybe this is a stupid question but I didn't find the answer.

I've to work with fixed length string:

string[] sName = new string[15];

the following instruction give back a compiler error:

sName="test";

"impossible to convert type string into string[]"

How can I set a string to string[] ?

Thank you in advance

Keven Corazza
 
Back
Top