well, structures are value types but the '=' opperator isnt supported for them.... I tried the Equals method and sounds like it works. Is that the best way to compare variables of structures?
Printable View
well, structures are value types but the '=' opperator isnt supported for them.... I tried the Equals method and sounds like it works. Is that the best way to compare variables of structures?
In C# you can overload operators which would do what you want, but VB you can't. You are going to have to probably go the other route if you do the structure in VB.
umm, I dont even know why "=" isnt supported for them:confused: so basically the Equals() function is the correct way for this, right?
Even when you compair two types like integers, it is overloading the = operator. When someone designed the integer class, they overloaded the = operator so when you compair two integers, it compairs the values that the class holds. If they didn't do this, then you would only be compairing two instances of the integer class. If those two variables didn't point to the same object, then they wouldn't be equal.
What I would do if I were you is create the structure in C#. Overload the = operator, then in VB when you create the instances of the struct, you could compair them with the = operator like you want to do.
I'll put that in the list so whenever I learn C# I would be able to do it:DQuote:
Originally posted by hellswraith
Even when you compair two types like integers, it is overloading the = operator. When someone designed the integer class, they overloaded the = operator so when you compair two integers, it compairs the values that the class holds. If they didn't do this, then you would only be compairing two instances of the integer class. If those two variables didn't point to the same object, then they wouldn't be equal.
What I would do if I were you is create the structure in C#. Overload the = operator, then in VB when you create the instances of the struct, you could compair them with the = operator like you want to do.
thanks for the info :)