I just have a question regarding C# list. I am a totally noob when it comes to programming and I'm really sorry for being a bird brainer. I am doing some practice coding and I am creating a simple program that will allow users to input names through textbox1 and then once they press the button1, the names will be stored in a List and will be output on textbox2.
I am having hard time storing the data from textbox1. Checked it online but I haven't found the right article for my concern so I'm trying my luck here.
Sorry guys, I forgot to mention I am using Winforms.
Thank you so much for the fast replies.
assuming winforms...
button1_Click
event add the text of textbox1
to the listhere is an example
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
list = new List<string>();
}
List<string> list;
private void button1_Click(object sender, EventArgs e)
{
list.Add(textBox1.Text);
string txt = "";
foreach(string s in list)
{
txt += s + " ";
}
textBox2.Text = txt;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With