For example:
C++:
union Foo
{
int i;
bool b;
};
C#:
using System.Runtime.InteropServices;
//C++ TO C# CONVERTER TODO TASK: Unions are not supported in C#, but the
following union can be simulated with the StructLayout and FieldOffset
attributes.
//ORIGINAL LINE: union Foo
[StructLayout(LayoutKind.Explicit)]
public struct Foo
{
[FieldOffset(0)]
public int i;
[FieldOffset(0)]
public bool b;
}
--
David Anton
http://www.tangiblesoftwaresolutions.com
Convert between VB, C#, and C++
Instant C#
Instant VB
Instant C++
C++ to C# Converter
C++ to VB Converter
"Eitan" wrote:
Hello,
I would like to have a structure similar to C++ Union. What would be the
best way to do it in C#?
Thanks
EitanB