我已經上課了,這是我製作的地址簿。 我在製作公共地址類對象變量時遇到了麻煩。我不知道如何編碼它。如何在C#中創建公共類級別的對象變量?
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
{
get
{
return strName;
}
set
{
strName = value;
}
} //end property Address
#endregion
//property Email Address
#region Email Address
public string EmailAddress
{
get
{
return strEmailAddress;
}
set
{
strEmailAddress = value;
}
} //end property Email Address
#endregion
//property Comment
#region Comment
public string Comment
{
get
{
return strComment;
}
set
{
strComment = value;
}
}//end property Comment
#endregion
//property Phone Number
#region Phone Number
public string PhoneNumber
{
get
{
return strPhoneNumber;
}
set
{
strPhoneNumber = value;
}
}
#endregion
//property Address
#region Address
public string address
{
get
{
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
}
}
「我無法使公共地址級別對象變量「 - Ca你是否可以改變這個?你可以給我們一小段代碼,它直接關係到你正在使用的問題(而不是整個班級) – Rob