I don't understand why my code exits my for loop after assigning x a value of 0 can someone please explain. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I don't understand why my code exits my for loop after assigning x a value of 0 can someone please explain.

I don't get why it enters the loop assigns x then exists the loop. I am writing on pc and asking here using examples of what Im working with on pc. https://code.sololearn.com/cChESHnuQk2o/?ref=app I'm working on pc only asking here so this is occurring on pc.

3rd Dec 2017, 3:20 AM
kenneth Stanley
kenneth Stanley - avatar
2 Answers
0
https://www.dotnetperls.com/array A array has a fixed size. So you have to define the number of elements string[] arr4 = new string[3]; arr4[0] = "one"; arr4[1] = "two"; arr4[2] = "three"; or initialized the elements upon definition. string[] arr1 = new string[] { "one", "two", "three" }; Can you use a list ? https://www.dotnetperls.com/list List<int> list = new List<int>();
3rd Dec 2017, 12:29 PM
sneeze
sneeze - avatar
0
A simple C# List for loop example.. List<object> list = new List<object>(); for (int i = 0; i < list.Count; i++) { SomeMethodThatDoesSomethingWithAnObject(list[i]); } http://csharp.net-informations.com/collection/list.htm
19th Dec 2019, 5:34 AM
garylinen