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 : 1914 | Status : [Member] | Replies : 2
i have a text box and a suer enter numbers
i need to add this num by using array




Responses

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

Up
0
Down
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()
{
InitializeComponent();
}

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
Thanks

If this post helps you mark it as answer
Thanks

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

Posted by: Sakthi.Singaravel on: 2/25/2013 [Member] Silver | Points: 25

Up
0
Down
what u r expecting...
Explain with example...

Regards,
Singaravel M

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

Login to post response