I am trying to declare an array of size 3, then use the string split() method to assign values to each index of the array. However, the Split() method seems to override the size of the array and sets its size to the amount of substrings the Split() method comes out with.
So This is what I did,
string myString = "Hello world";
string[] myArray = new string[3];
for(int i = 0; i < 3; i++)
myArray[i] = "";
myArray = myString.Split(' ');
But once again, when I use the Split() method, it overrides the size of my array and sets it to 2 which causes complications for me later on.
So I need to know how to use the split method to add strings into the array of size 3. If the array contains less than 3 items, I want to set the unassigned indexes to "" and if there are more than 3 substrings then I want to only take the first three and discard the rest.
Thanks in advance for any help guys.