Overriding the Defaults in a struct (c#)

前端 未结 12 1001
感情败类
感情败类 2021-01-04 00:47

Is it possible to set or override the default state for a structure?

As an example I have an

enum something{a,b,c,d,e};

and a struc

12条回答
  •  时光取名叫无心
    2021-01-04 01:25

    There is a workaround

    public struct MyStruct
    {
        public MyStruct(int h = 1, int l = 1)
        {
            high = h;
            low = l;
        }
        public int high;
        public int low;
    }
    

提交回复
热议问题