I have a struct like this
public struct InstrumentDefinition2 { public int instrumentId; public int Decimals; public long MinPriceIncrement_Mantissa; public short MinPriceIncrement_Exponent; public long RoundLot_Mantissa; public short RoundLot_Exponent; public char MsgType;
It is built from this C ++ structure through a delegate call:
typedef struct _InstrumentDefinition { int32_t instrumentId; int32_t Decimals; int64_t MinPriceIncrement_Mantissa; int16_t MinPriceIncrement_Exponent; int64_t RoundLot_Mantissa; int16_t RoundLot_Exponent; char MsgType;
It works great. I'm not sure if I can declare InstrumentDefinition2 as a class . But I like to declare InstrumentDefinition2 as a struct , I think of it as a "pointer to a C ++ memory block".
But during processing, I need to copy it to the class. So I want to declare a very similar C# class:
public class InstrumentDefinition { public int instrumentId; public int Decimals; public long MinPriceIncrement_Mantissa; public short MinPriceIncrement_Exponent; public long RoundLot_Mantissa; public short RoundLot_Exponent; public char MsgType;
And the question is, how can I copy InstrumentDefinition2 struct to the InstrumentDefinition class? Of course, I can assign all the fields one by one, but he:
- I think relatively slow
- with an error (what if a new field is introduced, and I forgot to add "handle" it?)
So can I do this anyway, without dealing with each field?
source share