All.
I'm newbie in C#. I know this is very popular question. But I didn't understand. I know there is a mistake, but where? For example - first part of code Form1 include private variable test, I need to get the value of this variable in the Form2. Where is the error?
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string test = "test this point";
Form2 dlg = new Form2();
dlg.test = test;
dlg.Show();
}
}
}
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 WindowsFormsApplication1
{
public partial class Form2 : Form
{
public string test { get; set; }
public Form2()
{
InitializeComponent();
label1.Text = test;
}
}
}