+ 1

Wondering if there is something I could do differently

So if I have 3 inputs, and the medium of those inputs is the output, Is there a way for it to count how many inputs I have automatically so I don’t have to divide it specifically by what I have already, which would be 3, like if I wanted the amount of inputs to be changeable, like you can put in 2, but you could also put in 3 or 4 inputs Sorry if my wording is terrible I’m not very good with words

9th Jun 2022, 5:40 PM
Zilly Cat
Zilly Cat - avatar
2 Answers
+ 1
Do you mean that you want to Count the Inputs you give out or that you want to make a special number of Inputs. For counting the Inputs would a list be good. List<string> animals = new List<string>(); string animal; while(animal != "stop") { animal = Console.ReadLine(); if(animal != "stop") { animals.Add(animal); } } Console.WriteLine(animals.Count); When you want to have a self decided number of Inputs just make a Input for that. Console.WriteLine("Give in a number of Inputs") List<string> Inputs = new List<string>(); int count = ToInt32(Console.ReadLine()); for(int i = 0; i <= count; i++) } Inputs.Add(Console.ReadLine()); }
10th Jun 2022, 12:40 PM
Felix Alcor
Felix Alcor - avatar
+ 2
You can specify the desired number of inputs in the first input and use this value in the loop for subsequent data input.
9th Jun 2022, 6:33 PM
Solo
Solo - avatar