Link to home
Start Free TrialLog in
Avatar of knowlegde
knowlegde

asked on

pass a class from a form to another form in visual studio 2005

I have a class person

class person
    {
        public person()
        {
           
        }
        protected string name;
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
In main form :
        private person NewPerson = new person();        
        private void button1_Click(object sender, EventArgs e)
        {
            Form2 frm = new Form2();
            frm.ShowDialog();
            NewPerson = frm.GetInfo();
        }
In form2 :
        person personal = new person();
        public person GetInfo()                     // ERROR HERE ????
        {
            return personal;
        }      
        private void Form2_Load(object sender, EventArgs e)
        {
            personal.Name = "Test Only";
        }
Error      1      Inconsistent accessibility: return type 'Project.person' is less accessible than method 'Project.Form2.GetInfo()'      
Note : everything working well in Visual studio 2003.
Pls help me !
ASKER CERTIFIED SOLUTION
Avatar of Ravi Singh
Ravi Singh
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike Tomlinson
Make sure your class person() has been declared as public...

    public class person
    {
        ...
I shoulda refreshed eh?...  =)
no worries :)
Avatar of knowlegde
knowlegde

ASKER

It's realy a silly mistake.Thank all. :)