Hi faezun, I think you should work on your general .net/OOP understanding. A constructor like you have given in your example NEVER returns a value!!!! (only the constructed object) So someproperty = new frmPerson(); never works (same in C++, Java...). Just expose properties and maybe initialize with parameterized constructor (like pashad showed you).
Maybe I can give you a similar (but full)example:
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
static class Program
{
[STAThread]
static void Main()
{
string strSomeProperty = "Hello Form!";
FormWithProperty form = new FormWithProperty(strSomeProperty);
form.ShowDialog();
MessageBox.Show("Property was: " + form.SomeProperty);
}
class FormWithProperty : Form
{
TextBox m_textbox;
public FormWithProperty() : this("DefaultString") { }
public FormWithProperty(string strSomeProperty)
{
InitializeComponentDummy();
SomeProperty = strSomeProperty;
}
private void InitializeComponentDummy()
{
m_textbox = new TextBox();
m_textbox.Multiline = true;
m_textbox.Dock = DockStyle.Fill;
Controls.Add(m_textbox);
}
public string SomeProperty
{
get { return m_textbox.Text; }
set { m_textbox.Text = value; }
}
}
}
}
(copy to a new WindowsForms-Project and replace the file Program.cs content with my example code -> run)