我怎样才能使用一个类使用点运算符
问题描述:
使用系统;我怎样才能使用一个类使用点运算符
我正在使用字符串[] 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;
}
}
}
答
可以使用数组初始化
agent.talentSlots = new string[] {focusTalent,reputationTalent};
注意,阵列型可以推断:'agent.talentSlots =新[] {focusTalent,reputationTalent}' –