C# Struct No Parameterless Constructor? See what I need to accomplish

前端 未结 6 566
既然无缘
既然无缘 2020-12-15 08:06

I am using a struct to pass to an unmanaged DLL as so -

[StructLayout(LayoutKind.Sequential)]
        public struct valTable
        {
            public byt         


        
6条回答
  •  执笔经年
    2020-12-15 09:06

    I would recommend to write this code.

    [StructLayout(LayoutKind.Sequential)]
    public struct valTable
    {
        public byte type;
        public byte map;
        public byte spare1;
        public byte spare2;
        public int par;
        public int min;
        public byte[] name;
    
        static public valTable Create()
        {
            valTable vT = new valTable();
            vT.name = new byte[24];
            return vT;
        }
    }
    

提交回复
热议问题