Premal Mehta

Premal Mehta

  • NA
  • 46
  • 6.1k

how to implement typedef struct union in C#

Jun 16 2016 10:48 AM

Hi guys,

I have to rewrite this C++ code in C#. C# does not support typedef or union. How can I do this in C# ?
 
typedef enum {
  TYPE_FLOAT, TYPE_STRING,TYPE_INTEGER, TYPE_DATETIME
   } tdFuncType;
 
typedef struct {
   char           szNm[256];          // Identifier name, if not constant or computed
  
tdFuncType ft;
   union {
       double         dFloat;           // TYPE_FLOAT
       long           lInteger;           // TYPE_INTEGER
       time_t         tDateTime;      // TYPE_DATETIME
       char           szString[256];  // TYPE_STRING, max string size is 255
       } val;
   } tdFuncValue;
 
// All values
typedef struct {
   long            lCt;     // Number of actual values: 1 to 11
   tdFuncValue  fv[11];  // Values
   } tdFuncValues;
 
Any ideas ?
 
Thanks.
 
Pr. 


 


Answers (2)