unions

How can I simulate a C++ union in C#?

I have a small question about structures with the LayoutKind.Explicit attribute set. I declared the struct as you can see, with a fieldTotal with 64 bits, being fieldFirst the first 32 bytes and fieldSecond the last 32 bytes. After setting both fieldfirst and fieldSecond to Int32.MaxValue, I'd expect fieldTotal to be Int64.MaxValue, whic...

(.net) Is there any intrinsic difference between .net Explicit structs and c++ unions?

That is the question. Is there anything you can do with c++ unions that you can't with c# Explicit structs? ...

Union on two tables with a where clause in the one

Currently I have 2 tables, both of the tables have the same structure and are going to be used in a web application. the two tables are production and temp. The temp table contains one additional column called [signed up]. Currently I generate a single list using two columns that are found in each table (recno and name). Using these two ...

Referencing a union inside a structure using union tag gives incorrect address

I had a need to declare a union inside a structure as defined below: struct MyStruct { int m_DataType; DWORD m_DataLen; union theData { char m_Buff [_MAX_PATH]; struct MyData m_myData; } m_Data; }; Initially, I tried accessing the union data as follows (before I added the m_Data declaration):...

c++ tables of unions and structures

I was told to write a program, that creates a union and structure, then creates two-element arrays of unions and structures and fills their fields. I have created a union and a structure, but how to fill their fields in arrays ? #include <iostream> #include <stdlib.h> #include <stdio.h> using namespace std; union complex; union comple...

How to write a Sql statement without using union?

Hi, I have a sql statement like below. How can I add a single row(code = 0, desc = 1) to result of this sql statement without using union keyword? thanks. select code, desc from material where material.ExpireDate ='2010/07/23' ...

Union (or Concat, etc..) with Constant values and projection.

I've discovered a very nasty gotcha with Linq-to-sql, and i'm not sure what the best solution is. If you take a simple L2S Union statement, and include L2S code in one side, and constants in the other, then the constants do not get included in the SQL Union and are only projected into the output after the SQL, resulting in SQL errors ab...

Stuff a class with user-defined constructors into a union

class Foo { Foo(int val) { /* Do some initialization */ } Foo() { /* Do nothing */ } }; union Bar { Foo foo; }; That code generates this error: error C2620: member 'Bar::foo' of union 'Bar' has user-defined constructor or non-trivial default constructor I understand why you'd throw that error if the constructor actually d...