How do I create public class level object variable in C#? -


i made class, address book making. having trouble making public address class level object variable. have no idea how code it.

namespace add_new_name {     class address     {         public string strname;         public string stremailaddress;         public string strcomment;         public string strphonenumber;         public string straddress;           //property name         #region property name         public string name          {                         {                 return strname;             }             set             {                 strname = value;             }         } //end property address          #endregion          //property email address         #region email address         public string emailaddress         {                         {                 return stremailaddress;             }             set             {                 stremailaddress = value;             }         } //end property email address         #endregion          //property comment         #region comment         public string comment         {                         {                 return strcomment;             }             set             {                 strcomment = value;             }         }//end property comment         #endregion          //property phone number         #region phone number         public string phonenumber         {                         {                 return strphonenumber;             }             set             {                 strphonenumber = value;             }         }         #endregion          //property address         #region address         public string address         {                         {                 return straddress;             }             set             {                 straddress = value;             }         }         #endregion          //constructor         #region constructor         public address (string sname, string semailaddress, string scomment, string sphonenumber, string saddress)         {             name = sname; //property name             emailaddress = semailaddress; //property address             comment = scomment; // property comment             phonenumber = sphonenumber; // property phone number             address = saddress; // property address          }         #endregion     } } 

try changing

class address 

to

public class address 

you can create object (edited show constructor parameters):

var myaddress = new address("me", "email", "code cool", "a number", "an address"); 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -