本文整理匯總了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