Help with strings and lists.
hello!
i´m createing program , internally uses list < > instead of
an array. input come text box , should possible insert
decimal numbers until user enters 0.0 input. then,
the highest , lowest , average printed out - button
making possible begin enter numbers again .
now problem. have completed, think, needed methods calculating highest, lowest , average.
my problem not know how continue!
thanks!
victor.
edit.
sorry swedish, here clarifications. medelvärde = average, högsta = highest, lägsta = lowest
namespace uppgift5._5 { public partial class form1 : form { public form1() { initializecomponent(); } private double medelvärde(list<int> lista) { int total = 0; double average; foreach (int resultat in lista) { total += resultat; } average = (double)total / lista.count; return average; } private double högsta(list<int> lista) { int högsta = lista[0]; (int index = 1; index < lista.count; index++) { if (lista[index] > högsta) { högsta = lista[index]; } } return högsta; } private double lägsta(list<int> lista) { int lägsta = lista[0]; (int index = 0; index < lista.count; index++) { if (lista[index] < lägsta) { lägsta = lista[index]; } } return lägsta; } private void button1_click(object sender, eventargs e) { } } }
why don't use linq aggregate functions query the list<t> and comeback results?
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment