我正在创建一个构造函数,需要从另一个类中获取所有变量。目前我有:
public class Person
{
public Person(Address.AddressDetails newAddress , string newTitle, string newForname, string newSurname, string newTel,
string newMob, string newEmail)
{
}
static public int ID;
static public string Title;
static public string Decorations;
static public string Forename;
static public string Surname;
static public string Telephone;
static public string Mobile;
static public string Email;
static public Address.AddressDetails Address;
}
Address.AddressDetails中的变量都是静态的。 如何使Person.Address表示AddressDetails类中的所有变量?
答案 0 :(得分:-1)
在构造函数中:
{
Person.Adress = newAdress;
}
答案 1 :(得分:-1)
public class Person
{
public static Assign(Address.AddressDetails newAddress , string newTitle, string newForname, string newSurname, string newTel,
string newMob, string newEmail)
{
Address = newAddress;
Email = newEmail;
....
...
}
static private int ID;
static private string Title;
static private string Decorations;
static private string Forename;
static private string Surname;
static private string Telephone;
static private string Mobile;
static private string Email;
static private Address.AddressDetails Address;
}
像这样的东西。
static public
方法以指定值private