C# union

  • Thread starter Thread starter Seefor
  • Start date Start date
S

Seefor

Is there anything equivalent to a union in C#?

I want to implement a Stat class, which can hold either an integer, float,
or string, but only one at a time.
What would be a good way of implementing this? I'm using version 1.1 of the
framework.

TIA.
 
1. You're using 1.0, not 1.1 - there is no CF 1.1
2. A union simply requires in memory the largest of the unioned members, so
you can define the managed member as a byte array the length of the longest
member, then use property accessors to return the data in the type format
you'd like.

--
Chris Tacke
Co-founder
OpenNETCF.org
Are you using the SDF? Let's do a case study.
Email us at d c s @ o p e n n e t c f . c o m
http://www.opennetcf.org/donate
 
Back
Top