public static void ToCharArray_Invalid()
{
// StartIndex < 0 or startIndex > string.Length
Assert.Throws<ArgumentOutOfRangeException>("startIndex", () => "foo".ToCharArray(-1, 0));
Assert.Throws<ArgumentOutOfRangeException>("startIndex", () => "foo".ToCharArray(4, 0)); // Start index > string.Length
// Length < 0 or length > string.Length
Assert.Throws<ArgumentOutOfRangeException>("length", () => "foo".ToCharArray(0, -1));
Assert.Throws<ArgumentOutOfRangeException>("startIndex", () => "foo".ToCharArray(0, 4));
// StartIndex + length > string.Length
Assert.Throws<ArgumentOutOfRangeException>("startIndex", () => "foo".ToCharArray(3, 1));
Assert.Throws<ArgumentOutOfRangeException>("startIndex", () => "foo".ToCharArray(2, 2));
}