Structures not behaving as value types
Richard Kucia <[email protected]> Fri, 22 Feb 2008 14:54:56 -0500
| Newsgroups | gmane.comp.windows.devel.dotnet.clr |
|---|---|
| Message-ID | <LISTSERV%[email protected]> |
I have a VB.Net declaration of a structure strFieldMask. The intended purpose is to store a bunch of bits, like a bit vector. The structure also has operator declarations for =, <>, And, Or, Not and <<, plus some other methods for bit manipulation. The problem is that variables of type strFieldMask seem to behave as though there was a singleton strFieldMask and all instances shared it. Consider this: Dim Mask1 as strFieldMask Dim Mask2 as strFieldMask Mask1 = (formula for computing the next unused mask value) Debug.WriteLine(Mask1.ToString)) Mask2 = (same formula) Debug.WriteLine(Mask1.ToString)) ' Yes, Mask1, not Mask2 The result from the first WriteLine might be "0x10" and the result from the second WriteLine might be "0x20". I've successfully used structures before, but this is the first time I've tried overloading the operators. Has that caused the behavior I'm seeing? Thanks. =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com