VB.NET Is - , . , Type.Equals , . .
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim X As New TestObject
Dim Y As New TestObject
If X Is Y Then MsgBox("The Same 1")
If Type.Equals(X, Y) Then MsgBox("The Same 2")
X = Y
If X Is Y Then MsgBox("The Same 3")
If Type.Equals(X, Y) Then MsgBox("The Same 4")
End Sub
End Class
Public Class TestObject
Public Value As Double
End Class
- 'equals' BASIC. VB4 IS, , , .
I suggest you search google and usenet for comments by Paul Wicks about why some individual BASIC idioms were ported and why others were not. I believe that in this case it would be possible to avoid confusion, since VB.NET introduced
ObjectA = ObjectC ', which forces ObjectA to reference the same objects that ObjectC refers to.
While in VB6, ObjectA = ObjectC was set
For the same reason, when objects were introduced into VB4 IS and Set, they were used to process the object instead of overloading equal.
Ultimately, these quirks became part of the Basic Coding Method.
source
share