M
Mike Smith
I've been working with C++ for years and am strugling at C#. I am trying to
reuse a COM object that I wrote that takes a chacter buffer and a size of
the buffer. I am having a problem "filling" in the memory buffer to pass to
my COM object. An example might be more explanatory.
public struct Data
{
ushort data_id;
ushort data_size;
}
Data my_data;
sbyte buf = new sbyte[8];
How do I copy the data structure into the buf array. Note that my data
structure can be any structure and can be variable length, thats why I can't
just to a simple ushort array. In C++ I would do something like this,
memcpy( buf, my_data, my_data.data_size ). I really can't seem to get my
mind around how to do this in C#.
Any help would be greatly appreciated.
Mike
reuse a COM object that I wrote that takes a chacter buffer and a size of
the buffer. I am having a problem "filling" in the memory buffer to pass to
my COM object. An example might be more explanatory.
public struct Data
{
ushort data_id;
ushort data_size;
}
Data my_data;
sbyte buf = new sbyte[8];
How do I copy the data structure into the buf array. Note that my data
structure can be any structure and can be variable length, thats why I can't
just to a simple ushort array. In C++ I would do something like this,
memcpy( buf, my_data, my_data.data_size ). I really can't seem to get my
mind around how to do this in C#.
Any help would be greatly appreciated.
Mike