-
Arrays
Quick question about arrays.
Is there any way to declare and initialize all elements of an array to one certain value without having to loop through the array.
Ex.
Code:
string[] myarray = new string[10] {"a","a","a","a",.............}
Instead of having to type every one, is there a way to initialize all elements to the same??????????????
Thanks,
Kendal
-
-
Well that is no good then.
Thanks for the reply,
Kendal
-
but you can write a static method to do that like:
Code:
public string [] init(string s, int len) {
string [] result = new string[len];
for (int i = 0; i < len; i++ ) result[i] = s;
return result;
}