2
Answers

the Array

Ask a question
Johnny Nguyen

Johnny Nguyen

13y
1.5k
1
When I run the code bellow in the console application I got the error " Index was outside the bounds of the array". Why do I get the error and how to fix it?

static void Main(string[]args)
{
        string aString= "This is a string";
        string [] sArray= aString.Split(' ');
        Console.WriteLine(sArray[sArray.Length]);
}

I thinks,should I convert the sArray.Length to int because it still be a string form. right? 

Answers (2)