unions in c#
hey c# experts, I want to know how to create unions in c# & work with them. can anyone give me a sample code?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Mike GoldPosted Jun 12, 2007, 1:45 PM
Thanks for pointing that out.
AlanPosted Jun 12, 2007, 5:42 AM
http://msdn2.microsoft.com/en-us/library/ya9bz4ha(vs.80).aspx
If you don't mind using 'unsafe' code, then in C# 2.0 you can also use a fixed sized char buffer to represent a string within a union, as the buffer (rather than a pointer thereto) is actually embedded into the struct's memory and so is treated as a value type:
http://msdn2.microsoft.com/en-us/library/zycewsya(VS.80).aspx
Mike GoldPosted Jun 12, 2007, 2:33 AM
http://msdn2.microsoft.com/En-US/library/acxa5b99(VS.80).aspx
Best,