using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Array
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
const int s = 2;
int[] A = new int[s];
int[] B = new int[s];
// int[] C = new int[s];
int i = 0;
private void button1_Click(object sender, EventArgs e)
{ add(A, B);
//(C.ToString());//چرا اینجا برنامه مقدارها را برنمیگرداند؟ در تریس برنامه کاملا اجرا میشده
}
public void add(int[] a, int[] b)//void
{
int[] c = new int[s];
for (int i = 0; i < s; i++)
{
c[i] = a[i] + b[i];
listBox1.Items.Add(c[i].ToString());//
}
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\r')
{
A[i] = Convert.ToInt32(textBox1.Text);
i++;
if (i < s)
textBox1.Text = "";
else
{
MessageBox.Show("Enough...");
i = 0;
}
}
}
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\r')
{
B[i] = Convert.ToInt32(textBox2.Text);
i++;
if (i < s)
textBox2.Text = "";
else
{
MessageBox.Show("Enough...");
i = 0;
}
}
}
علاقه مندی ها (Bookmarks)