Sorry if this question has already been asked I just can't find how to do it in my problem. I imported a file with a list of numbers from 1-20 into a listbox and then displayed the total amount of values and average into textboxes. I'm getting the right calculations it's just I have no clue how to convert them.
My code is:
int i = 0;
int result = 0;
while (i < lstbxDisplayInfo.Items.Count)
{
result += Convert.ToInt32(lstbxDisplayInfo.Items[i++]);
}
//Displays average.
txtAverage.Text = Convert.ToString((double)result / i);
//Displays Amount.
txtAmount.Text = Convert.ToString((double) i);
my output is:
Average: 10.5
Total Amount: 20
I need the output to be:
Average: 10.50
Total Amount: 20.00