0
Why is my code not working?
I'm new to coding and I'm learning C# as my first language. Can you tell me what is wrong with my code, I'm using visual studio to create my codes and then I put them into Sololearn's playground. I'm using 2022 Visual Studio. Here is my code. int[ ] b = {11, 12, 13, 14, 15, 16, 17, 18,}; Console.WriteLine(b[11]); Console.WriteLine(b[12]);
5 Answers
+ 3
jolly elmroot
You are accessing 11th and 12th index value in array b which doesn't exist because array b has only 8 elements. So you can access till 7th index as index start from 0
+ 2
indexing starts with 0 and your array only has 8 integers. So try printing with the index values 0 - 7
+ 2
Thank you guys Iāll try this!
+ 2
Thank you guys, I get it now! I realized that I put the elements in the Console.WriteLineā¦ that was my mistake. Iāll post it in playground!