本文整理汇总了VB.NET中System.String.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:VB.NET String.GetHashCode方法的具体用法?VB.NET String.GetHashCode怎么用?VB.NET String.GetHashCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.String
的用法示例。
在下文中一共展示了String.GetHashCode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: GetHashCode
Module GetHashCode
Sub Main()
DisplayHashCode("")
DisplayHashCode("a")
DisplayHashCode("ab")
DisplayHashCode("abc")
DisplayHashCode("abd")
DisplayHashCode("abe")
DisplayHashCode("abcdef")
DisplayHashCode("abcdeg")
DisplayHashCode("abcdeh")
DisplayHashCode("abcdei")
DisplayHashCode("Abcdeg")
DisplayHashCode("Abcdeh")
DisplayHashCode("Abcdei")
End Sub
Sub DisplayHashCode(Operand As String)
Dim HashCode As Integer = Operand.GetHashCode()
Console.WriteLine("The hash code for ""{0}"" is: 0x{1:X8}, {1}",
Operand, HashCode)
End Sub
End Module
' This example displays output like the following:
' The hash code for "" is: 0x2D2816FE, 757602046
' The hash code for "a" is: 0xCDCAB7BF, -842352705
' The hash code for "ab" is: 0xCDE8B7BF, -840386625
' The hash code for "abc" is: 0x2001D81A, 536991770
' The hash code for "abd" is: 0xC2A94CB5, -1029092171
' The hash code for "abe" is: 0x6550C150, 1699791184
' The hash code for "abcdef" is: 0x1762906D, 392335469
' The hash code for "abcdeg" is: 0x1763906D, 392401005
' The hash code for "abcdeh" is: 0x175C906D, 391942253
' The hash code for "abcdei" is: 0x175D906D, 392007789
' The hash code for "Abcdeg" is: 0x1763954D, 392402253
' The hash code for "Abcdeh" is: 0x175C954D, 391943501
' The hash code for "Abcdei" is: 0x175D954D, 392009037
示例2: Example
Module Example
Public Sub Main()
' Show hash code in current domain.
Dim display As New DisplayString()
display.ShowStringHashCode()
' Create a new app domain and show string hash code.
Dim domain As AppDomain = AppDomain.CreateDomain("NewDomain")
Dim display2 = CType(domain.CreateInstanceAndUnwrap(GetType(Example).Assembly.FullName,
"DisplayString"), DisplayString)
display2.ShowStringHashCode()
End Sub
End Module
Public Class DisplayString : Inherits MarshalByRefObject
Private s As String = "This is a string."
Public Overrides Function Equals(obj As Object) As Boolean
Dim s2 As String = TryCast(obj, String)
If s2 Is Nothing Then
Return False
Else
Return s = s2
End If
End Function
Public Overloads Function Equals(str As String) As Boolean
Return s = str
End Function
Public Overrides Function GetHashCode() As Integer
Return s.GetHashCode()
End Function
Public Overrides Function ToString() As String
Return s
End Function
Public Sub ShowStringHashCode()
Console.WriteLine("String '{0}' in domain '{1}': {2:X8}",
s, AppDomain.CurrentDomain.FriendlyName,
s.GetHashCode())
End Sub
End Class
示例3: String.GetHashCode()
public class Test
public Shared Sub Main
Dim Number As String
Number = "4"
Console.WriteLine(Integer.Parse(Number))
Console.WriteLine(Number.GetHashCode())
End Sub
End class