-1

別のクラスからすべての変数を取得する必要があるコンストラクターを作成しています。現時点で私は持っています:

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 クラスのすべての変数を表すようにするにはどうすればよいですか?

4

2 に答える 2

-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
于 2012-04-10T09:55:18.343 に答える
-1

コンストラクターで:

{
    Person.Adress = newAdress;
}
于 2012-04-10T09:51:52.200 に答える