Вы находитесь на странице: 1из 1

Program to enter elements in 1-D Array

using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

namespace _1DArray { public partial class Form1 : Form { public Form1() { InitializeComponent(); label2.Text = ""; } int index = 0; int[] arr = new int[5]; private void button1_Click(object sender, EventArgs e) { if (index > 4) { MessageBox.Show("Array is full"); textBox1.Text = ""; } else { arr[index] = Convert.ToInt32(textBox1.Text); label2.Text = label2.Text + arr[index] + " "; index++; textBox1.Text = ""; textBox1.Focus(); } } } }

Вам также может понравиться