如何使用点运算符将类与数组一起使用

时间:2016-08-30 21:21:06

标签: c# arrays class

使用System;

  

我正在使用string [] 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;
        }
    }
}

1 个答案:

答案 0 :(得分:2)

您可以使用数组初始值设定项

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