本文整理汇总了VB.NET中System.Object.ReferenceEquals方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Object.ReferenceEquals方法的具体用法?VB.NET Object.ReferenceEquals怎么用?VB.NET Object.ReferenceEquals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了Object.ReferenceEquals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: App
Public Class App
Public Shared Sub Main()
Dim o As Object = Nothing
Dim p As Object = Nothing
Dim q As New Object
Console.WriteLine(Object.ReferenceEquals(o, p))
p = q
Console.WriteLine(Object.ReferenceEquals(p, q))
Console.WriteLine(Object.ReferenceEquals(o, p))
End Sub
End Class
输出:
True True False
示例2: Example
Public Module Example
Public Sub Main
Dim int1 As Integer = 3
Console.WriteLine(Object.ReferenceEquals(int1, int1))
Console.WriteLine(int1.GetType().IsValueType)
End Sub
End Module
输出:
False True
示例3: Example
Module Example
Public Sub Main()
Dim s1 As String = "String1"
Dim s2 As String = "String1"
Console.WriteLine("s1 = s2: {0}", Object.ReferenceEquals(s1, s2))
Console.WriteLine("{0} interned: {1}", s1,
If(String.IsNullOrEmpty(String.IsInterned(s1)), "No", "Yes"))
Dim suffix As String = "A"
Dim s3 = "String" + suffix
Dim s4 = "String" + suffix
Console.WriteLine("s3 = s4: {0}", Object.ReferenceEquals(s3, s4))
Console.WriteLine("{0} interned: {1}", s3,
If(String.IsNullOrEmpty(String.IsInterned(s3)), "No", "Yes"))
End Sub
End Module
输出:
s1 = s2: True String1 interned: Yes s3 = s4: False StringA interned: No