how to get textbox value in array and add them on button click

Posted by Shanky11 under C# on 2/25/2013 | Points: 10 | Views : 2093 | Status : [Member] | Replies : 1
i have a text box and a suer enter numbers
i need to add this num by using array


Posted by: Satyapriyanayak on: 2/25/2013 [Member] [MVP] Silver | Points: 25

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 WindowsFormsApplication8
public partial class Form2 : Form
int[] n1 = new int[3];

public Form2()

private void button1_Click(object sender, EventArgs e)

int value;

if (int.TryParse(textBox1.Text, out value))
n1[0] = value;
if (int.TryParse(textBox2.Text, out value))
n1[1] = value;
if (int.TryParse(textBox3.Text, out value))
n1[2] = value;
textBox4.Text = n1.Sum().ToString();


If this post helps you mark it as answer

If this post helps you mark it as answer

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response