- Home /
Question by
corapeca · Oct 22, 2020 at 11:03 PM ·
c#classconstructor
Can i set class vars automatically when calling class constructor with attributes?
Hi, i have this class...
public class cSkill
{
public string skillBackEndName;
public string skillFrontEndName;
public string comboid;
cSkill()
{
}
public cSkill(string aSkillBackEndName, string aSkillFrontEndName, string aComboid) // a for attribute
{
skillBackEndName = aSkillBackEndName;
skillFrontEndName = aSkillFrontEndName;
comboid = aComboid;
}
}
make a skill in another code...
skills.add(new cSkill("base.attack1", "Whirlwind", "c1"));
so my question is, can i set those values to class vars automatically without having to bind each attribute with each class var?
public class cSkill
{
public string skillBackEndName;
public string skillFrontEndName;
public string comboid;
cSkill()
{
}
public cSkill(string aSkillBackEndName, string aSkillFrontEndName, string aComboid) // a for attribute
{
// automatic value setting up
}
}
Comment