2012-04-10 4 views
-1

다른 클래스의 모든 변수를 가져와야하는 생성자를 만듭니다. 현재 내가 가지고있는 것 :클래스의 정적 멤버를 사용하여 개체 만들기

Address.AddressDetails의 변수도 모두 정적입니다. Person.Address를 AddressDetails 클래스의 모든 변수로 나타내려면 어떻게해야합니까? 생성자에서

+1

의 모든 구성원을 static public 방법은 값

  • 를 할당 할 수 있도록? –

  • +0

    이러한 모든 정적 공개 필드가 매우 나쁜 디자인입니다. 그들은'Person'의 모든 경우에 걸쳐 공유 될 것입니다. - 이유는 무엇입니까? – Oded

    +0

    다른 정적 필드에서 복사하는 것은 이상한 일입니다. –

    답변

    -1

    이 같은

    { 
        Person.Adress = newAdress; 
    } 
    
    -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;  
    
    } 
    

    뭔가.

    • 왜 당신이 정기적으로 생성자와 함께 모든 정적 필드를 사용하는 클래스 private
    +0

    @downvoter : 설명해 주시겠습니까? – Tigran

    관련 문제