My Problem is...
I have a form and two classes (Class1 And Class2) when i enter the data in to the form the values are assigned to Class1 Members what i want is the values assigned to class1 members accessible in class2. I am using Visual Studio 2008
Here is the code
Code for Form:
Expand|Select|Wrap|Line Numbers
- using System;
- using System.Windows.Forms;
- namespace Simple_Dal_Test
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void label2_Click(object sender, EventArgs e)
- {
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- MyClass1 MyName = new MyClass1();
- MyName.Name = textBox1.Text;
- MyClass1 MyPh = new MyClass1();
- MyPh.Ph = textBox2.Text;
- }
- }
- }
Expand|Select|Wrap|Line Numbers
- namespace Simple_Dal_Test
- {
- public class MyClass1
- {
- private string _Name;
- private string _Ph;
- public string Name
- {
- get { return _Name; }
- set { _Name = value; }
- }
- public string Ph
- {
- get { return _Ph; }
- set { _Ph = value; }
- }
- }
- }
Expand|Select|Wrap|Line Numbers
- namespace Simple_Dal_Test
- {
- public class MyClass2
- {
- MyClass1 MyN = new MyClass1();
- MyClass1 MyP = new MyClass1();
- }
- }