I initialize a variable g consisting of only digits not exceeding 2, then I initialize a bool array consisting of three elements and at f[g[0]] I get an exception, “The index was outside the bounds of the array.” since f[3] why g[0] = f.length always regardless of the length of g and the value of g[0] ?
string g = “022”;
bool[] f = { true, true, true };
Console.WriteLine(f[(int)g[0]]);
Console.ReadLine();
New contributor
Саша Голованов is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.