2016-08-30 66 views
-4

使用系統;我怎樣才能使用一個類使用點運算符

我正在使用字符串[] talentSlots = new string [2]; ,我想做一個agent.talentSlots =等等等等等等,我該怎麼做?

namespace warhammerRPGCB 
{ 
    public class classes 
    { 
     string className; 
     int stanceRed; 
     int standGreen; 
     string carrerSkills; 
     string primaryChar; 
     string[] talentSlots = new string[2]; 
     int focusSlot; 
     int reputationSlot; 
     int tacticSlot; 

     public classes() 
     { 
      classes agent = new classes(); 
      agent.className = "Agent"; 
      agent.carrerSkills = "Charm, Education, Folklore, Guile, Intution"; 
      agent.stanceRed = 2; 
      agent.standGreen = 2; 
      agent.primaryChar = "Intelligence, Felloship"; 
      agent.tacticSlot = focusTalent, reputationTalent; 
     } 
    } 
} 

回答

2

可以使用數組初始化

agent.talentSlots = new string[] {focusTalent,reputationTalent}; 
+2

注意,陣列型可以推斷:'agent.talentSlots =新[] {focusTalent,reputationTalent}' –