I’ve a C++ interface having a public property “P” which accepts bit value like 5, 6,7 etc.
Its documentation says:”Set bit mask of group type. Bit 5 is for ‘a’, Bit 6 is for ‘b’,etc.”
Am using this interface in my C# class and the type of this property “P” shown in the metadata is “char” in VS.Net.
How do I pass the bit value of 6 and 7, to this property from my C# code?
Please note that, as mentioned above, a value of type “char” should be passed from C# to this C++ interface, as this is the type which is shown in the metadata in VS.net
Please suggest.
Code:
C++ interface definition as seen from VS.Net IDE–
[SuppressUnmanagedCodeSecurity]
[Guid("f274179c-6d8a-11d2-90fc-00806fa6792c")]
[InterfaceType(1)]
public interface IAccount
{
char GroupType { get; set; }
}
C#:
IAccount objAccount= new AccountClass();
((IAccount)objAccount).GroupType = ??//I need to pass char value here
Thanks.
The
chartype in C++ is always 8 bits, which presumably means that you’d use abyteto represent the same thing in C#. (This assumes that your C++ platform uses standard 8-bit bytes, since a C++charis defined as being 1 byte, but a C++ “byte” isn’t necessarily guaranteed to be 8 bits!)I’m not sure how you’d marshal that value back to your C++ routine, if that’s what you need to do.