This example finds largest value from array list.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
int[] arr = { 75,75,73};
Label1.Text = LargestVal(arr).ToString();
}
}
private int LargestVal(int[] list)
{
int maxVal = 0;
for (int i = 0; i < list.Length; i++)
{
if (list[i] > maxVal)
maxVal = list[i];
}
return maxVal;
}
No comments:
Post a Comment