private void button1_Click(object sender, EventArgs e)
{
    int[] m = new int[1000];
    int n = textBox1.Lines.Lenght;
    int i;
    int k = 0;
    int sum = 0;
    int product = 1;
    int average = 0;
    for (i = 0; i < n; i++)
    {
        try 
        {
            m[k] = Convert.ToInt32(textBox1.Lines[i]);
            sum = sum + m[k];
            product = product * m[k];
            average = sum / n;
        }     
        catch 
        {
            MessangeBox.Show("Буквы нельзя!!");
            k++;
        }
    }
    label10.Text = n.ToString();
    label11.Text = sum.ToString();
    label12.Text = product.ToString();
    label13.Text = average.ToString();     
}
    - 
        your question is little bit unclear. can you explain your problem more?Khairul Islam– Khairul Islam2016-04-14 18:39:11 +00:00Commented Apr 14, 2016 at 18:39
 - 
        Use Max and Min to find the largest number or smallest number in your array.Icemanind– Icemanind2016-04-14 19:20:41 +00:00Commented Apr 14, 2016 at 19:20
 
                    
                        Add a comment
                    
                 | 
            
                
            
        
         
    2 Answers
The following should help:
private void button1_Click(object sender, EventArgs e)
{
    int[] m = new int[1000];
    int n = textBox1.Lines.Lenght;
    int i;
    int k = 0;
    int sum = 0;
    int product = 1;
    int average = 0;
    int min = Int32.MaxValue;   // will hold min value
    int max = Int32.MinValue;   // will hold max value
    for (i = 0; i < n; i++)
    {
        try 
        {
            m[k] = Convert.ToInt32(textBox1.Lines[i]);
            sum = sum + m[k];
            product = product * m[k];
            if (m[k] < min)
              min = m[k];
            if (m[k] > max)
              max = m[k];
        }     
        catch 
        {
            MessageBox.Show("Буквы нельзя!!");
            k++;
        }
    }
    average = sum / n;  //Computing average here is more efficient
    label10.Text = n.ToString();
    label11.Text = sum.ToString();
    label12.Text = product.ToString();
    label13.Text = average.ToString();     
}
Caveat: If your array is empty, you may not want to have Int32.MaxValue and Int32.MinValue as your default min and max. You will need to handle that case separately.
1 Comment
Matthew Watson
 This is the most efficient solution, I think.
  using System;
using System.Collections.Generic;
using System.Linq;
int[] m = new int[1000];
// fill in the array here .....
int min = m.Min(); // find the minimum
int max = m.Max(); // find the maximum
    3 Comments
Jian Huang
 care to explain why there are down votes? He wants to know how to find minimum and maximum of the array.
  Carlos Torrecillas
 I agree, that's the sort of answer I would be looking for!
  Matthew Watson
 No idea why it was downvoted. Have an upvote. :) However, it would be more efficient to compute the max and min in the existing loop in the OP's code rather than loop through all the elements an extra two times.