I am new to C # and visual studio, but not programming at all. I searched for the answer to my question for 3 days, and I found a lot of them, but for some strange reason (I'm sure I miss something very obvious). I can not make it work. I think this is the easiest question as I ask. I have a form (Form3) with a text box and a button (I configured it for testing purposes only). I want to fill out and read this text box from another class. I understand that the most appropriate way to do this is to create a property in Form3.cs using GET and SET accessors. I did it, but I can't get it to work. I do not receive any error messages, but I also cannot set the value of the text field. It just stays empty. Here is my sample code:
namespace WindowsFormsApplication1
{
public partial class Form3 : Form
{
public string setCodes
{
get { return test1.Text; }
set { test1.Text = value; }
}
public Form3()
{
InitializeComponent();
}
private void Form3_Load(object sender, EventArgs e)
{ }
private void button1_Click(object sender, EventArgs e)
{
a.b();
}
}
public class a
{
public static void b()
{
Form3 v = new Form3();
v.setCodes = "abc123";
}
}
}
Can someone help me solve this problem?