IDL Complex Type
union

The CORBA union indicates (TBD) .....  . 

It maps to C#'s union type.

// CORBA IDL
module demo
{
   module unions 
   {
      union Nums switch (char)
      {
         case 'f': float f;
         case 'l': long l;
         default: short s;
      };
   };
};
e.g.
Nums
NumsHelper
// C# 
					
[Serializable]
public sealed class Nums : Org.Omg.CORBA.Portable.IDLEntity
{
   /**
   * Union member _d
   */
   private char __d;

   /**
   * Union member f
   */
   private float _f;

   /**
   * Union member l
   */
   private int _l;

   /**
   * Union member s
   */
   private short _s;

   /**
   * Default constructor
   */
   public Nums()
   {
      __d = '1';
   }

   /**
   * Get/Set discriminator value
   */
   public char discriminator
   {
      get
      {
         return __d;
      }
      set
      {
         __d = value;
      }
   }

   /**
   * Get/Set f value
   */
   public float f
   {
      set
      {
         __d = (char)('f');
         _f = value;
      }
      get
      {
         return _f;
      }
   }

   /**
   * Get/Set l value
   */
   public int l
   {
      set
      {
         __d = (char)('l');
         _l = value;
      }
      get
      {
         return _l;
      }
   }

   /**
   * Get/Set s value
   */
   public short s
   {
      set
      {
         __d = '1';
         _s = value;
      }
      get
      {
         return _s;
      }
   }

   /**
   * Set s value
   */
   public void Set_Discriminator_And_S(char dvalue, short value)
   {
      __d = dvalue;
      _s = value;
   }
}

public class NumsHelper
{
   ///
   /// Insert Nums into an any
   /// @param a an any
   /// @param t Nums value
   ///
   public static void Insert(Org.Omg.CORBA.Any a, demo.unions.Nums t )
   {
      a.Type(Type());
      Write(a.Create_Output_Stream(),t);
   }

   ///
   /// Extract Nums from an any
   /// @param a an any
   /// @return the extracted Nums value
   ///
   public static demo.unions.Nums Extract(Org.Omg.CORBA.Any a)
   {
      if (!a.Type().Equal(Type()))
         throw new Org.Omg.CORBA.MARSHAL();
      return Read(a.Create_Input_Stream());
   }

   ///
   /// Internal TypeCode value
   ///
   private static Org.Omg.CORBA.TypeCode _tc = null;
   private static bool _working = false;

   ///
   /// Return the Nums TypeCode
   /// @return a TypeCode
   ///
   public static Org.Omg.CORBA.TypeCode Type()
   {
      if (_tc == null)
      {
         lock (typeof(Org.Omg.CORBA.TypeCode))
         {
            if (_tc != null)
               return _tc;
            if (_working)
               return Org.Omg.CORBA.ORB.Init().Create_Recursive_TC(Id());
            _working = true;
            Org.Omg.CORBA.ORB orb = Org.Omg.CORBA.ORB.Init();
            Org.Omg.CORBA.UnionMember[] _members = new Org.Omg.CORBA.UnionMember[3];
            Org.Omg.CORBA.Any any;

            any = orb.Create_Any();
            any.Insert_Char((char)('f'));
            _members[0] = new Org.Omg.CORBA.UnionMember();
            _members[0].name = "f";
            _members[0].label = any;
            _members[0].type = orb.Get_Primitive_TC(Org.Omg.CORBA.TCKind.tk_float);
            any = orb.Create_Any();
            any.Insert_Char((char)('l'));
            _members[1] = new Org.Omg.CORBA.UnionMember();
            _members[1].name = "l";
            _members[1].label = any;
            _members[1].type = orb.Get_Primitive_TC(Org.Omg.CORBA.TCKind.tk_long);
            any = orb.Create_Any();
            any.Insert_Octet((byte) 0);
            _members[2] = new Org.Omg.CORBA.UnionMember();
            _members[2].name = "s";
            _members[2].label = any;
            _members[2].type = orb.Get_Primitive_TC(Org.Omg.CORBA.TCKind.tk_short);
            _tc = orb.Create_Union_TC(Id(),"Nums",orb.Get_Primitive_TC(Org.Omg.CORBA.TCKind.tk_char),_members);
            _working = false;
         }
      }
      return _tc;
   }

   ///
   /// Return the Nums IDL ID
   /// @return an ID
   ///
   public static string Id()
   {
      return _id;
   }

   private static string _id = "IDL:demo/unions/Nums:1.0";

   ///
   /// Read Nums from a marshalled stream
   /// @param istream the input stream
   /// @return the readed Nums value
   ///
   public static demo.unions.Nums Read(Org.Omg.CORBA.Portable.InputStream istream)
   {
      demo.unions.Nums new_one = new demo.unions.Nums();

      new_one.discriminator = istream.Read_Char();
      if (new_one.discriminator == (char)'f')
      {
         new_one.f = istream.Read_Float();
      }
      else if (new_one.discriminator == (char)'l')
      {
         new_one.l = istream.Read_Long();
      }
      else
      {
         new_one.s = istream.Read_Short();
      }
      return new_one;
   }

   ///
   /// Write Nums into a marshalled stream
   /// @param ostream the output stream
   /// @param value Nums value
   ///
   public static void Write(Org.Omg.CORBA.Portable.OutputStream ostream, demo.unions.Nums value)
   {
      ostream.Write_Char(value.discriminator);
      if (value.discriminator ==(char) 'f')
      {
         ostream.Write_Float(value.f);
      }
      else if (value.discriminator ==(char) 'l')
      {
         ostream.Write_Long(value.l);
      }
      else
      {
         ostream.Write_Short(value.s);
      }
   }
}