Initialize field in base class

2 posts / 0 new
Last post
Last seen: 11 months 2 weeks ago
Joined: 05/27/2020
Posts: 1
Initialize field in base class
Is this valid?  If not, is there a way to do something like this where I can initialize a field in a parent class with a const in a child class?

valuetype MyBaseValueType  {
    public string  member;

valuetype MyValueType:
MyBaseValueType  {
    public const string member2 = "Member Name";
    member = member2; 

valuetype Message: MyValueType{
    public long data;
Last seen: 15 hours 52 min ago
Joined: 04/02/2013
Posts: 161

You can try the @default annotation to set a default value for a field:


struct Test {

@default("Hello") string str;

@default(43) int32 value;