At the minute I am able to add values into a textbox and then save those values into an array, I want to calculate the Mode/Most frequent values, for this array and output into another textbox or something to display on my web-page.
e.g. I enter 2,2,2,3,3,3,1. the output to webpage will be 2 3.
string[] list = TextBox1.Text.Split(new string[] { "," },
StringSplitOptions.RemoveEmptyEntries);
int[] numbers = new int[list.Length];
for (int i = 0; i < numbers.Length; i++)
{
numbers[i] = Convert.ToInt32(list[i].Trim());
}
int mode = numbers
.GroupBy(x => x)
.OrderByDescending(g => g.Count())
.First()
.Key;
TextBox2.Text = mode.ToString();