So I have this piece of code:
static void Main(string[] args)
{
string name = "John; Jill;";
string[] arrayOfString = new string[6];
arrayOfString = name.Split(';');
for(int i = 0; i < arrayOfString.Length; i++)
{
if (String.IsNullOrEmpty(arrayOfString[i]))
{
arrayOfString[i] = "EMPTY";
}
Console.WriteLine(arrayOfString[i].Trim());
}
}
If I ran this code, then the result is:
John
Jill
EMPTY
But what I want to do is display it to something like this:
John
Jill
EMPTY
EMPTY
EMPTY
EMPTY
I tried using length as you can see, but it only counts the elements in array that already has a value in it. Can anyone help me with this problem? Thanks in advance.