How do i accept user input in a C# array? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do i accept user input in a C# array?

Hello! It's me again. This time i would like to know how can i let the user input numbers of his choice in a C# array or list and then use the numbers that he gave me to maybe add them up for example. Thank you !

9th Jun 2017, 8:28 AM
Andrew Bratu
Andrew Bratu - avatar
3 Answers
0
Oh sorry i forgot to mention. It is an "int"
9th Jun 2017, 8:58 AM
Andrew Bratu
Andrew Bratu - avatar
0
for(int i = 0; i < yourArray.lentgh; i++) { yourArray[i] = Convert.ToInt32(Console.ReadLine()); } that should do it
9th Jun 2017, 9:04 AM
Edi Lipovac
Edi Lipovac - avatar
0
thanks!
9th Jun 2017, 9:14 AM
Andrew Bratu
Andrew Bratu - avatar