当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET CompareInfo.LastIndexOf方法代码示例

本文整理汇总了VB.NET中System.Globalization.CompareInfo.LastIndexOf方法的典型用法代码示例。如果您正苦于以下问题:VB.NET CompareInfo.LastIndexOf方法的具体用法?VB.NET CompareInfo.LastIndexOf怎么用?VB.NET CompareInfo.LastIndexOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Globalization.CompareInfo的用法示例。


在下文中一共展示了CompareInfo.LastIndexOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: SamplesCompareInfo

' 导入命名空间
Imports System.Globalization

Public Class SamplesCompareInfo

   Public Shared Sub Main()

      ' Creates CompareInfo for the InvariantCulture.
      Dim myComp As CompareInfo = CultureInfo.InvariantCulture.CompareInfo

      ' iS is the starting index of the substring.
      Dim [iS] As Integer = 8
      ' iL is the length of the substring.
      Dim iL As Integer = 18
      ' myT1 and myT2 are the strings used for padding.
      Dim myT1 As New [String]("-"c, [iS])
      Dim myT2 As [String]

      ' Searches for the ligature Æ.
      Dim myStr As [String] = "Is AE or ae the same as Æ or æ?"
      myT2 = New [String]("-"c, myStr.Length - [iS] - iL)
      Console.WriteLine()
      Console.WriteLine("Original      : {0}", myStr)
      Console.WriteLine("No options    : {0}{1}{2}", myT1, myStr.Substring([iS], iL), myT2)
      PrintMarker("           AE : ", myComp.IndexOf(myStr, "AE", [iS], iL), myComp.LastIndexOf(myStr, "AE", [iS] + iL - 1, iL))
      PrintMarker("           ae : ", myComp.IndexOf(myStr, "ae", [iS], iL), myComp.LastIndexOf(myStr, "ae", [iS] + iL - 1, iL))
      PrintMarker("            Æ : ", myComp.IndexOf(myStr, "Æ"c, [iS], iL), myComp.LastIndexOf(myStr, "Æ"c, [iS] + iL - 1, iL))
      PrintMarker("            æ : ", myComp.IndexOf(myStr, "æ"c, [iS], iL), myComp.LastIndexOf(myStr, "æ"c, [iS] + iL - 1, iL))
      Console.WriteLine("Ordinal       : {0}{1}{2}", myT1, myStr.Substring([iS], iL), myT2)
      PrintMarker("           AE : ", myComp.IndexOf(myStr, "AE", [iS], iL, CompareOptions.Ordinal), myComp.LastIndexOf(myStr, "AE", [iS] + iL - 1, iL, CompareOptions.Ordinal))
      PrintMarker("           ae : ", myComp.IndexOf(myStr, "ae", [iS], iL, CompareOptions.Ordinal), myComp.LastIndexOf(myStr, "ae", [iS] + iL - 1, iL, CompareOptions.Ordinal))
      PrintMarker("            Æ : ", myComp.IndexOf(myStr, "Æ"c, [iS], iL, CompareOptions.Ordinal), myComp.LastIndexOf(myStr, "Æ"c, [iS] + iL - 1, iL, CompareOptions.Ordinal))
      PrintMarker("            æ : ", myComp.IndexOf(myStr, "æ"c, [iS], iL, CompareOptions.Ordinal), myComp.LastIndexOf(myStr, "æ"c, [iS] + iL - 1, iL, CompareOptions.Ordinal))
      Console.WriteLine("IgnoreCase    : {0}{1}{2}", myT1, myStr.Substring([iS], iL), myT2)
      PrintMarker("           AE : ", myComp.IndexOf(myStr, "AE", [iS], iL, CompareOptions.IgnoreCase), myComp.LastIndexOf(myStr, "AE", [iS] + iL - 1, iL, CompareOptions.IgnoreCase))
      PrintMarker("           ae : ", myComp.IndexOf(myStr, "ae", [iS], iL, CompareOptions.IgnoreCase), myComp.LastIndexOf(myStr, "ae", [iS] + iL - 1, iL, CompareOptions.IgnoreCase))
      PrintMarker("            Æ : ", myComp.IndexOf(myStr, "Æ"c, [iS], iL, CompareOptions.IgnoreCase), myComp.LastIndexOf(myStr, "Æ"c, [iS] + iL - 1, iL, CompareOptions.IgnoreCase))
      PrintMarker("            æ : ", myComp.IndexOf(myStr, "æ"c, [iS], iL, CompareOptions.IgnoreCase), myComp.LastIndexOf(myStr, "æ"c, [iS] + iL - 1, iL, CompareOptions.IgnoreCase))

      ' Searches for the combining character sequence Latin capital letter U with diaeresis or Latin small letter u with diaeresis.
      myStr = "Is " & ChrW(&H0055) & ChrW(&H0308) & " or " & ChrW(&H0075) & ChrW(&H0308) & " the same as " & ChrW(&H00DC) & " or " & ChrW(&H00FC) & "?"
      myT2 = New [String]("-"c, myStr.Length - [iS] - iL)
      Console.WriteLine()
      Console.WriteLine("Original      : {0}", myStr)
      Console.WriteLine("No options    : {0}{1}{2}", myT1, myStr.Substring([iS], iL), myT2)
      PrintMarker("           U" & ChrW(&H0308) & " : ", myComp.IndexOf(myStr, "U" & ChrW(&H0308), [iS], iL), myComp.LastIndexOf(myStr, "U" & ChrW(&H0308), [iS] + iL - 1, iL))
      PrintMarker("           u" & ChrW(&H0308) & " : ", myComp.IndexOf(myStr, "u" & ChrW(&H0308), [iS], iL), myComp.LastIndexOf(myStr, "u" & ChrW(&H0308), [iS] + iL - 1, iL))
      PrintMarker("            Ü : ", myComp.IndexOf(myStr, "Ü"c, [iS], iL), myComp.LastIndexOf(myStr, "Ü"c, [iS] + iL - 1, iL))
      PrintMarker("            ü : ", myComp.IndexOf(myStr, "ü"c, [iS], iL), myComp.LastIndexOf(myStr, "ü"c, [iS] + iL - 1, iL))
      Console.WriteLine("Ordinal       : {0}{1}{2}", myT1, myStr.Substring([iS], iL), myT2)
      PrintMarker("           U" & ChrW(&H0308) & " : ", myComp.IndexOf(myStr, "U" & ChrW(&H0308), [iS], iL, CompareOptions.Ordinal), myComp.LastIndexOf(myStr, "U" & ChrW(&H0308), [iS] + iL - 1, iL, CompareOptions.Ordinal))
      PrintMarker("           u" & ChrW(&H0308) & " : ", myComp.IndexOf(myStr, "u" & ChrW(&H0308), [iS], iL, CompareOptions.Ordinal), myComp.LastIndexOf(myStr, "u" & ChrW(&H0308), [iS] + iL - 1, iL, CompareOptions.Ordinal))
      PrintMarker("            Ü : ", myComp.IndexOf(myStr, "Ü"c, [iS], iL, CompareOptions.Ordinal), myComp.LastIndexOf(myStr, "Ü"c, [iS] + iL - 1, iL, CompareOptions.Ordinal))
      PrintMarker("            ü : ", myComp.IndexOf(myStr, "ü"c, [iS], iL, CompareOptions.Ordinal), myComp.LastIndexOf(myStr, "ü"c, [iS] + iL - 1, iL, CompareOptions.Ordinal))
      Console.WriteLine("IgnoreCase    : {0}{1}{2}", myT1, myStr.Substring([iS], iL), myT2)
      PrintMarker("           U" & ChrW(&H0308) & " : ", myComp.IndexOf(myStr, "U" & ChrW(&H0308), [iS], iL, CompareOptions.IgnoreCase), myComp.LastIndexOf(myStr, "U" & ChrW(&H0308), [iS] + iL - 1, iL, CompareOptions.IgnoreCase))
      PrintMarker("           u" & ChrW(&H0308) & " : ", myComp.IndexOf(myStr, "u" & ChrW(&H0308), [iS], iL, CompareOptions.IgnoreCase), myComp.LastIndexOf(myStr, "u" & ChrW(&H0308), [iS] + iL - 1, iL, CompareOptions.IgnoreCase))
      PrintMarker("            Ü : ", myComp.IndexOf(myStr, "Ü"c, [iS], iL, CompareOptions.IgnoreCase), myComp.LastIndexOf(myStr, "Ü"c, [iS] + iL - 1, iL, CompareOptions.IgnoreCase))
      PrintMarker("            ü : ", myComp.IndexOf(myStr, "ü"c, [iS], iL, CompareOptions.IgnoreCase), myComp.LastIndexOf(myStr, "ü"c, [iS] + iL - 1, iL, CompareOptions.IgnoreCase))

   End Sub

   Public Shared Sub PrintMarker(Prefix As [String], First As Integer, Last As Integer)

      ' Determines the size of the array to create.
      Dim mySize As Integer
      If Last > First Then
         mySize = Last
      Else
         mySize = First
      End If 

      If mySize > - 1 Then

         ' Creates an array of Char to hold the markers.
         Dim myCharArr(mySize + 1) As [Char]

         ' Inserts the appropriate markers.
         If First > - 1 Then
            myCharArr(First) = "f"c
         End If
         If Last > - 1 Then
            myCharArr(Last) = "l"c
         End If
         If First = Last Then
            myCharArr(First) = "b"c
         End If 

         ' Displays the array of Char as a String.
         Console.WriteLine("{0}{1}", Prefix, New [String](myCharArr))

      Else
         Console.WriteLine(Prefix)

      End If 

   End Sub

End Class
开发者ID:VB.NET开发者,项目名称:System.Globalization,代码行数:99,代码来源:CompareInfo.LastIndexOf

输出:

Original      : Is AE or ae the same as Æ or æ?
No options    : -------- ae the same as Æ -----
AE :                         b
ae :          b
Æ :                         b
æ :          b
Ordinal       : -------- ae the same as Æ -----
AE :
ae :          b
Æ :                         b
æ :
IgnoreCase    : -------- ae the same as Æ -----
AE :          f              l
ae :          f              l
Æ :          f              l
æ :          f              l

Original      : Is U" or u" the same as Ü or ü?
No options    : -------- u" the same as Ü -----
U" :                         b
u" :          b
Ü :                         b
ü :          b
Ordinal       : -------- u" the same as Ü -----
U" :
u" :          b
Ü :                         b
ü :
IgnoreCase    : -------- u" the same as Ü -----
U" :          f              l
u" :          f              l
Ü :          f              l
ü :          f              l

示例2: Example

' 导入命名空间
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim ci As CompareInfo = CultureInfo.CurrentCulture.CompareInfo
      
      Dim softHyphen As Char = ChrW(&h00AD)
      Dim position As Integer
      
      Dim s1 As String = "ani" + softHyphen + "mal"
      Dim s2 As String = "animal"
      
      ' Find the index of the soft hyphen using culture-sensitive comparison.
      position = ci.LastIndexOf(s1, "m"c)
      Console.WriteLine("'m' at position {0}", position)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s1, softHyphen, position, _
                           position + 1, CompareOptions.IgnoreCase))
      End If
      
      position = ci.LastIndexOf(s2, "m"c)
      Console.WriteLine("'m' at position {0}", position)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s2, softHyphen, position, _
                           position + 1, CompareOptions.IgnoreCase))
      End If  
       
      ' Find the index of the soft hyphen using ordinal comparison.
      position = ci.LastIndexOf(s1, "m"c)
      Console.WriteLine("'m' at position {0}", position)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s1, softHyphen, position, _
                           position + 1, CompareOptions.Ordinal))
      End If
      
      position = ci.LastIndexOf(s2, "m"c)
      Console.WriteLine("'m' at position {0}", position)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s2, softHyphen, position, _
                           position + 1, CompareOptions.Ordinal))
      End If   
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Globalization,代码行数:44,代码来源:CompareInfo.LastIndexOf

输出:

m' at position 4
4
m' at position 3
3
m' at position 4
3
m' at position 3
-1

示例3: Example

' 导入命名空间
Imports System.Globalization

Public Module Example
   Public Sub Main()
      Dim ci As CompareInfo = CultureInfo.CurrentCulture.CompareInfo

      Dim searchString As String = ChrW(&h00AD) + "m"
      Dim s1 As String = "ani" + ChrW(&h00AD) + "mal" 
      Dim s2 As String = "animal"
      Dim position As Integer

      position = ci.LastIndexOf(s1, "m"c)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s1, searchString, position, 3, CompareOptions.None))
         Console.WriteLine(ci.LastIndexOf(s1, searchString, position, 3, CompareOptions.Ordinal))
      End If
      
      position = ci.LastIndexOf(s2, "m"c)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s2, searchString, position, 3, CompareOptions.None))
         Console.WriteLine(ci.LastIndexOf(s2, searchString, position, 3, CompareOptions.Ordinal))
      End If
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Globalization,代码行数:25,代码来源:CompareInfo.LastIndexOf

输出:

4
3
3
-1

示例4: Example

' 导入命名空间
Imports System.Globalization

Public Module Example
   Public Sub Main()
      Dim ci As CompareInfo = CultureInfo.CurrentCulture.CompareInfo

      Dim searchString As String = ChrW(&h00AD) + "m"
      Dim s1 As String = "ani" + ChrW(&h00AD) + "m" 
      Dim s2 As String = "animal"
      Dim position As Integer

      position = ci.LastIndexOf(s1, "m"c)
      If position >= 1 Then
         Console.WriteLine(ci.LastIndexOf(s1, searchString, position, position, CompareOptions.None))
         Console.WriteLine(ci.LastIndexOf(s1, searchString, position, position, CompareOptions.Ordinal))
      End If      
      
      position = ci.LastIndexOf(s2, "m"c)
      If position >= 1 Then 
         Console.WriteLine(ci.LastIndexOf(s2, searchString, position, position, CompareOptions.None))
         Console.WriteLine(ci.LastIndexOf(s2, searchString, position, position, CompareOptions.Ordinal))
      End If
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Globalization,代码行数:25,代码来源:CompareInfo.LastIndexOf

输出:

4
3
3
-1

示例5: SamplesCompareInfo

' 导入命名空间
Imports System.Globalization

Public Class SamplesCompareInfo

   Public Shared Sub Main()

      ' Creates CompareInfo for the InvariantCulture.
      Dim myComp As CompareInfo = CultureInfo.InvariantCulture.CompareInfo

      ' iS is the starting index of the substring.
      Dim [iS] As Integer = 20
      ' myT1 is the string used for padding.
      Dim myT1 As [String]

      ' Searches for the ligature Æ.
      Dim myStr As [String] = "Is AE or ae the same as Æ or æ?"
      Console.WriteLine()

      myT1 = New [String]("-"c, [iS])
      Console.WriteLine("IndexOf( String, *, {0}, * )", [iS])
      Console.WriteLine("Original      : {0}", myStr)
      Console.WriteLine("No options    : {0}{1}", myT1, myStr.Substring([iS]))
      PrintMarker("           AE : ", myComp.IndexOf(myStr, "AE", [iS]), - 1)
      PrintMarker("           ae : ", myComp.IndexOf(myStr, "ae", [iS]), - 1)
      PrintMarker("            Æ : ", myComp.IndexOf(myStr, "Æ"c, [iS]), - 1)
      PrintMarker("            æ : ", myComp.IndexOf(myStr, "æ"c, [iS]), - 1)
      Console.WriteLine("Ordinal       : {0}{1}", myT1, myStr.Substring([iS]))
      PrintMarker("           AE : ", myComp.IndexOf(myStr, "AE", [iS], CompareOptions.Ordinal), - 1)
      PrintMarker("           ae : ", myComp.IndexOf(myStr, "ae", [iS], CompareOptions.Ordinal), - 1)
      PrintMarker("            Æ : ", myComp.IndexOf(myStr, "Æ"c, [iS], CompareOptions.Ordinal), - 1)
      PrintMarker("            æ : ", myComp.IndexOf(myStr, "æ"c, [iS], CompareOptions.Ordinal), - 1)
      Console.WriteLine("IgnoreCase    : {0}{1}", myT1, myStr.Substring([iS]))
      PrintMarker("           AE : ", myComp.IndexOf(myStr, "AE", [iS], CompareOptions.IgnoreCase), - 1)
      PrintMarker("           ae : ", myComp.IndexOf(myStr, "ae", [iS], CompareOptions.IgnoreCase), - 1)
      PrintMarker("            Æ : ", myComp.IndexOf(myStr, "Æ"c, [iS], CompareOptions.IgnoreCase), - 1)
      PrintMarker("            æ : ", myComp.IndexOf(myStr, "æ"c, [iS], CompareOptions.IgnoreCase), - 1)

      myT1 = New [String]("-"c, myStr.Length - [iS] - 1)
      Console.WriteLine("LastIndexOf( String, *, {0}, * )", [iS])
      Console.WriteLine("Original      : {0}", myStr)
      Console.WriteLine("No options    : {0}{1}", myStr.Substring(0, [iS] + 1), myT1)
      PrintMarker("           AE : ", - 1, myComp.LastIndexOf(myStr, "AE", [iS]))
      PrintMarker("           ae : ", - 1, myComp.LastIndexOf(myStr, "ae", [iS]))
      PrintMarker("            Æ : ", - 1, myComp.LastIndexOf(myStr, "Æ"c, [iS]))
      PrintMarker("            æ : ", - 1, myComp.LastIndexOf(myStr, "æ"c, [iS]))
      Console.WriteLine("Ordinal       : {0}{1}", myStr.Substring(0, [iS] + 1), myT1)
      PrintMarker("           AE : ", - 1, myComp.LastIndexOf(myStr, "AE", [iS], CompareOptions.Ordinal))
      PrintMarker("           ae : ", - 1, myComp.LastIndexOf(myStr, "ae", [iS], CompareOptions.Ordinal))
      PrintMarker("            Æ : ", - 1, myComp.LastIndexOf(myStr, "Æ"c, [iS], CompareOptions.Ordinal))
      PrintMarker("            æ : ", - 1, myComp.LastIndexOf(myStr, "æ"c, [iS], CompareOptions.Ordinal))
      Console.WriteLine("IgnoreCase    : {0}{1}", myStr.Substring(0, [iS] + 1), myT1)
      PrintMarker("           AE : ", - 1, myComp.LastIndexOf(myStr, "AE", [iS], CompareOptions.IgnoreCase))
      PrintMarker("           ae : ", - 1, myComp.LastIndexOf(myStr, "ae", [iS], CompareOptions.IgnoreCase))
      PrintMarker("            Æ : ", - 1, myComp.LastIndexOf(myStr, "Æ"c, [iS], CompareOptions.IgnoreCase))
      PrintMarker("            æ : ", - 1, myComp.LastIndexOf(myStr, "æ"c, [iS], CompareOptions.IgnoreCase))

      ' Searches for the combining character sequence Latin capital letter U with diaeresis or Latin small letter u with diaeresis.
      myStr = "Is " & ChrW(&H0055) & ChrW(&H0308) & " or " & ChrW(&H0075) & ChrW(&H0308) & " the same as " & ChrW(&H00DC) & " or " & ChrW(&H00FC) & "?"
      Console.WriteLine()

      myT1 = New [String]("-"c, [iS])
      Console.WriteLine("IndexOf( String, *, {0}, * )", [iS])
      Console.WriteLine("Original      : {0}", myStr)
      Console.WriteLine("No options    : {0}{1}", myT1, myStr.Substring([iS]))
      PrintMarker("           U" & ChrW(&H0308) & " : ", myComp.IndexOf(myStr, "U" & ChrW(&H0308), [iS]), - 1)
      PrintMarker("           u" & ChrW(&H0308) & " : ", myComp.IndexOf(myStr, "u" & ChrW(&H0308), [iS]), - 1)
      PrintMarker("            Ü : ", myComp.IndexOf(myStr, "Ü"c, [iS]), - 1)
      PrintMarker("            ü : ", myComp.IndexOf(myStr, "ü"c, [iS]), - 1)
      Console.WriteLine("Ordinal       : {0}{1}", myT1, myStr.Substring([iS]))
      PrintMarker("           U" & ChrW(&H0308) & " : ", myComp.IndexOf(myStr, "U" & ChrW(&H0308), [iS], CompareOptions.Ordinal), - 1)
      PrintMarker("           u" & ChrW(&H0308) & " : ", myComp.IndexOf(myStr, "u" & ChrW(&H0308), [iS], CompareOptions.Ordinal), - 1)
      PrintMarker("            Ü : ", myComp.IndexOf(myStr, "Ü"c, [iS], CompareOptions.Ordinal), - 1)
      PrintMarker("            ü : ", myComp.IndexOf(myStr, "ü"c, [iS], CompareOptions.Ordinal), - 1)
      Console.WriteLine("IgnoreCase    : {0}{1}", myT1, myStr.Substring([iS]))
      PrintMarker("           U" & ChrW(&H0308) & " : ", myComp.IndexOf(myStr, "U" & ChrW(&H0308), [iS], CompareOptions.IgnoreCase), - 1)
      PrintMarker("           u" & ChrW(&H0308) & " : ", myComp.IndexOf(myStr, "u" & ChrW(&H0308), [iS], CompareOptions.IgnoreCase), - 1)
      PrintMarker("            Ü : ", myComp.IndexOf(myStr, "Ü"c, [iS], CompareOptions.IgnoreCase), - 1)
      PrintMarker("            ü : ", myComp.IndexOf(myStr, "ü"c, [iS], CompareOptions.IgnoreCase), - 1)

      myT1 = New [String]("-"c, myStr.Length - [iS] - 1)
      Console.WriteLine("LastIndexOf( String, *, {0}, * )", [iS])
      Console.WriteLine("Original      : {0}", myStr)
      Console.WriteLine("No options    : {0}{1}", myStr.Substring(0, [iS] + 1), myT1)
      PrintMarker("           U" & ChrW(&H0308) & " : ", - 1, myComp.LastIndexOf(myStr, "U" & ChrW(&H0308), [iS]))
      PrintMarker("           u" & ChrW(&H0308) & " : ", - 1, myComp.LastIndexOf(myStr, "u" & ChrW(&H0308), [iS]))
      PrintMarker("            Ü : ", - 1, myComp.LastIndexOf(myStr, "Ü"c, [iS]))
      PrintMarker("            ü : ", - 1, myComp.LastIndexOf(myStr, "ü"c, [iS]))
      Console.WriteLine("Ordinal       : {0}{1}", myStr.Substring(0, [iS] + 1), myT1)
      PrintMarker("           U" & ChrW(&H0308) & " : ", - 1, myComp.LastIndexOf(myStr, "U" & ChrW(&H0308), [iS], CompareOptions.Ordinal))
      PrintMarker("           u" & ChrW(&H0308) & " : ", - 1, myComp.LastIndexOf(myStr, "u" & ChrW(&H0308), [iS], CompareOptions.Ordinal))
      PrintMarker("            Ü : ", - 1, myComp.LastIndexOf(myStr, "Ü"c, [iS], CompareOptions.Ordinal))
      PrintMarker("            ü : ", - 1, myComp.LastIndexOf(myStr, "ü"c, [iS], CompareOptions.Ordinal))
      Console.WriteLine("IgnoreCase    : {0}{1}", myStr.Substring(0, [iS] + 1), myT1)
      PrintMarker("           U" & ChrW(&H0308) & " : ", - 1, myComp.LastIndexOf(myStr, "U" & ChrW(&H0308), [iS], CompareOptions.IgnoreCase))
      PrintMarker("           u" & ChrW(&H0308) & " : ", - 1, myComp.LastIndexOf(myStr, "u" & ChrW(&H0308), [iS], CompareOptions.IgnoreCase))
      PrintMarker("            Ü : ", - 1, myComp.LastIndexOf(myStr, "Ü"c, [iS], CompareOptions.IgnoreCase))
      PrintMarker("            ü : ", - 1, myComp.LastIndexOf(myStr, "ü"c, [iS], CompareOptions.IgnoreCase))

   End Sub

   Public Shared Sub PrintMarker(Prefix As [String], First As Integer, Last As Integer)

      ' Determines the size of the array to create.
      Dim mySize As Integer
      If Last > First Then
         mySize = Last
      Else
         mySize = First
      End If 

      If mySize > - 1 Then

         ' Creates an array of Char to hold the markers.
         Dim myCharArr(mySize + 1) As [Char]

         ' Inserts the appropriate markers.
         If First > - 1 Then
            myCharArr(First) = "f"c
         End If
         If Last > - 1 Then
            myCharArr(Last) = "l"c
         End If
         If First = Last Then
            myCharArr(First) = "b"c
         End If 

         ' Displays the array of Char as a String.
         Console.WriteLine("{0}{1}", Prefix, New [String](myCharArr))
      
      Else
         Console.WriteLine(Prefix)

      End If 

   End Sub

End Class
开发者ID:VB.NET开发者,项目名称:System.Globalization,代码行数:138,代码来源:CompareInfo.LastIndexOf

输出:

IndexOf( String, *, 20, * )
Original      : Is AE or ae the same as Æ or æ?
No options    : -------------------- as Æ or æ?
AE :                         f
ae :                              f
Æ :                         f
æ :                              f
Ordinal       : -------------------- as Æ or æ?
AE :
ae :
Æ :                         f
æ :                              f
IgnoreCase    : -------------------- as Æ or æ?
AE :                         f
ae :                         f
Æ :                         f
æ :                         f
LastIndexOf( String, *, 20, * )
Original      : Is AE or ae the same as Æ or æ?
No options    : Is AE or ae the same ----------
AE :    l
ae :          l
Æ :    l
æ :          l
Ordinal       : Is AE or ae the same ----------
AE :    l
ae :          l
Æ :
æ :
IgnoreCase    : Is AE or ae the same ----------
AE :          l
ae :          l
Æ :          l
æ :          l

IndexOf( String, *, 20, * )
Original      : Is U" or u" the same as Ü or ü?
No options    : -------------------- as Ü or ü?
U" :                         f
u" :                              f
Ü :                         f
ü :                              f
Ordinal       : -------------------- as Ü or ü?
U" :
u" :
Ü :                         f
ü :                              f
IgnoreCase    : -------------------- as Ü or ü?
U" :                         f
u" :                         f
Ü :                         f
ü :                         f
LastIndexOf( String, *, 20, * )
Original      : Is U" or u" the same as Ü or ü?
No options    : Is U" or u" the same ----------
U" :    l
u" :          l
Ü :    l
ü :          l
Ordinal       : Is U" or u" the same ----------
U" :    l
u" :          l
Ü :
ü :
IgnoreCase    : Is U" or u" the same ----------
U" :          l
u" :          l
Ü :          l
ü :          l

示例6: Example

' 导入命名空间
Imports System.Globalization

Public Module Example
   Public Sub Main()
      Dim ci As CompareInfo = CultureInfo.CurrentCulture.CompareInfo

      Dim searchString As String = ChrW(&h00AD) + "m"
      Dim s1 As String = "ani" + ChrW(&h00AD) + "mal" 
      Dim s2 As String = "animal"
      Dim position As Integer

      position = ci.LastIndexOf(s1, "m"c)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s1, searchString, position, CompareOptions.None))
         Console.WriteLine(ci.LastIndexOf(s1, searchString, position, CompareOptions.Ordinal))
      End If
      
      position = ci.LastIndexOf(s2, "m"c)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s2, searchString, position, CompareOptions.None))
         Console.WriteLine(ci.LastIndexOf(s2, searchString, position, CompareOptions.Ordinal))
      End If
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Globalization,代码行数:25,代码来源:CompareInfo.LastIndexOf

输出:

4
3
3
-1

示例7: Example

' 导入命名空间
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim ci As CompareInfo = CultureInfo.CurrentCulture.CompareInfo
      
      Dim position As Integer
      Dim softHyphen As Char = ChrW(&h00AD)
      Dim s1 As String = "ani" + softHyphen + "mal"
      Dim s2 As String = "animal"
      
      ' Find the index of the soft hyphen.
      position = ci.IndexOf(s1, "m"c)
      Console.WriteLine("'m' at position {0}", position)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s1, softHyphen, position, position + 1))
      End If
      
      position = ci.IndexOf(s2, "m"c)
      Console.WriteLine("'m' at position {0}", position)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s2, softHyphen, position, position + 1))
      End If   
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Globalization,代码行数:26,代码来源:CompareInfo.LastIndexOf

输出:

m' at position 4
4
m' at position 3
3

示例8: Example

' 导入命名空间
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim ci As CompareInfo = CultureInfo.CurrentCulture.CompareInfo
      
      Dim softHyphen As Char = ChrW(&h00AD)
      Dim position As Integer
      
      Dim s1 As String = "ani" + softHyphen + "mal"
      Dim s2 As String = "animal"
      
      ' Find the index of the soft hyphen using culture-sensitive comparison.
      position = ci.LastIndexOf(s1, "m"c)
      Console.WriteLine("'m' at position {0}", position)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s1, softHyphen, position, CompareOptions.IgnoreCase))
      End If
      
      position = ci.LastIndexOf(s2, "m"c)
      Console.WriteLine("'m' at position {0}", position)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s2, softHyphen, position, CompareOptions.IgnoreCase))
      End If  
       
      ' Find the index of the soft hyphen using ordinal comparison.
      position = ci.LastIndexOf(s1, "m"c)
      Console.WriteLine("'m' at position {0}", position)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s1, softHyphen, position, CompareOptions.Ordinal))
      End If
      
      position = ci.LastIndexOf(s2, "m"c)
      Console.WriteLine("'m' at position {0}", position)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s2, softHyphen, position, CompareOptions.Ordinal))
      End If   
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Globalization,代码行数:40,代码来源:CompareInfo.LastIndexOf

输出:

m' at position 4
4
m' at position 3
3
m' at position 4
3
m' at position 3
-1

示例9: SamplesCompareInfo

' 导入命名空间
Imports System.Globalization

Public Class SamplesCompareInfo

   Public Shared Sub Main()

      ' Creates CompareInfo for the InvariantCulture.
      Dim myComp As CompareInfo = CultureInfo.InvariantCulture.CompareInfo

      ' Searches for the ligature Æ.
      Dim myStr As [String] = "Is AE or ae the same as Æ or æ?"
      Console.WriteLine()
      Console.WriteLine("No options    : {0}", myStr)
      PrintMarker("           AE : ", myComp.IndexOf(myStr, "AE"), myComp.LastIndexOf(myStr, "AE"))
      PrintMarker("           ae : ", myComp.IndexOf(myStr, "ae"), myComp.LastIndexOf(myStr, "ae"))
      PrintMarker("            Æ : ", myComp.IndexOf(myStr, "Æ"c), myComp.LastIndexOf(myStr, "Æ"c))
      PrintMarker("            æ : ", myComp.IndexOf(myStr, "æ"c), myComp.LastIndexOf(myStr, "æ"c))
      Console.WriteLine("Ordinal       : {0}", myStr)
      PrintMarker("           AE : ", myComp.IndexOf(myStr, "AE", CompareOptions.Ordinal), myComp.LastIndexOf(myStr, "AE", CompareOptions.Ordinal))
      PrintMarker("           ae : ", myComp.IndexOf(myStr, "ae", CompareOptions.Ordinal), myComp.LastIndexOf(myStr, "ae", CompareOptions.Ordinal))
      PrintMarker("            Æ : ", myComp.IndexOf(myStr, "Æ"c, CompareOptions.Ordinal), myComp.LastIndexOf(myStr, "Æ"c, CompareOptions.Ordinal))
      PrintMarker("            æ : ", myComp.IndexOf(myStr, "æ"c, CompareOptions.Ordinal), myComp.LastIndexOf(myStr, "æ"c, CompareOptions.Ordinal))
      Console.WriteLine("IgnoreCase    : {0}", myStr)
      PrintMarker("           AE : ", myComp.IndexOf(myStr, "AE", CompareOptions.IgnoreCase), myComp.LastIndexOf(myStr, "AE", CompareOptions.IgnoreCase))
      PrintMarker("           ae : ", myComp.IndexOf(myStr, "ae", CompareOptions.IgnoreCase), myComp.LastIndexOf(myStr, "ae", CompareOptions.IgnoreCase))
      PrintMarker("            Æ : ", myComp.IndexOf(myStr, "Æ"c, CompareOptions.IgnoreCase), myComp.LastIndexOf(myStr, "Æ"c, CompareOptions.IgnoreCase))
      PrintMarker("            æ : ", myComp.IndexOf(myStr, "æ"c, CompareOptions.IgnoreCase), myComp.LastIndexOf(myStr, "æ"c, CompareOptions.IgnoreCase))

      ' Searches for the combining character sequence Latin capital letter U with diaeresis or Latin small letter u with diaeresis.
      myStr = "Is " & ChrW(&H0055) & ChrW(&H0308) & " or " & ChrW(&H0075) & ChrW(&H0308) & " the same as " & ChrW(&H00DC) & " or " & ChrW(&H00FC) & "?"
      Console.WriteLine()
      Console.WriteLine("No options    : {0}", myStr)
      PrintMarker("           U" & ChrW(&H0308) & " : ", myComp.IndexOf(myStr, "U" & ChrW(&H0308)), myComp.LastIndexOf(myStr, "U" & ChrW(&H0308)))
      PrintMarker("           u" & ChrW(&H0308) & " : ", myComp.IndexOf(myStr, "u" & ChrW(&H0308)), myComp.LastIndexOf(myStr, "u" & ChrW(&H0308)))
      PrintMarker("            Ü : ", myComp.IndexOf(myStr, "Ü"c), myComp.LastIndexOf(myStr, "Ü"c))
      PrintMarker("            ü : ", myComp.IndexOf(myStr, "ü"c), myComp.LastIndexOf(myStr, "ü"c))
      Console.WriteLine("Ordinal       : {0}", myStr)
      PrintMarker("           U" & ChrW(&H0308) & " : ", myComp.IndexOf(myStr, "U" & ChrW(&H0308), CompareOptions.Ordinal), myComp.LastIndexOf(myStr, "U" & ChrW(&H0308), CompareOptions.Ordinal))
      PrintMarker("           u" & ChrW(&H0308) & " : ", myComp.IndexOf(myStr, "u" & ChrW(&H0308), CompareOptions.Ordinal), myComp.LastIndexOf(myStr, "u" & ChrW(&H0308), CompareOptions.Ordinal))
      PrintMarker("            Ü : ", myComp.IndexOf(myStr, "Ü"c, CompareOptions.Ordinal), myComp.LastIndexOf(myStr, "Ü"c, CompareOptions.Ordinal))
      PrintMarker("            ü : ", myComp.IndexOf(myStr, "ü"c, CompareOptions.Ordinal), myComp.LastIndexOf(myStr, "ü"c, CompareOptions.Ordinal))
      Console.WriteLine("IgnoreCase    : {0}", myStr)
      PrintMarker("           U" & ChrW(&H0308) & " : ", myComp.IndexOf(myStr, "U" & ChrW(&H0308), CompareOptions.IgnoreCase), myComp.LastIndexOf(myStr, "U" & ChrW(&H0308), CompareOptions.IgnoreCase))
      PrintMarker("           u" & ChrW(&H0308) & " : ", myComp.IndexOf(myStr, "u" & ChrW(&H0308), CompareOptions.IgnoreCase), myComp.LastIndexOf(myStr, "u" & ChrW(&H0308), CompareOptions.IgnoreCase))
      PrintMarker("            Ü : ", myComp.IndexOf(myStr, "Ü"c, CompareOptions.IgnoreCase), myComp.LastIndexOf(myStr, "Ü"c, CompareOptions.IgnoreCase))
      PrintMarker("            ü : ", myComp.IndexOf(myStr, "ü"c, CompareOptions.IgnoreCase), myComp.LastIndexOf(myStr, "ü"c, CompareOptions.IgnoreCase))

   End Sub

   Public Shared Sub PrintMarker(Prefix As [String], First As Integer, Last As Integer)

      ' Determines the size of the array to create.
      Dim mySize As Integer
      If Last > First Then
         mySize = Last
      Else
         mySize = First
      End If 

      If mySize > - 1 Then

         ' Creates an array of Char to hold the markers.
         Dim myCharArr(mySize + 1) As [Char]

         ' Inserts the appropriate markers.
         If First > - 1 Then
            myCharArr(First) = "f"c
         End If
         If Last > - 1 Then
            myCharArr(Last) = "l"c
         End If
         If First = Last Then
            myCharArr(First) = "b"c
         End If 
         ' Displays the array of Char as a String.
         Console.WriteLine("{0}{1}", Prefix, New [String](myCharArr))

      Else
         Console.WriteLine(Prefix)

      End If 

   End Sub

End Class
开发者ID:VB.NET开发者,项目名称:System.Globalization,代码行数:86,代码来源:CompareInfo.LastIndexOf

输出:

No options    : Is AE or ae the same as Æ or æ?
AE :    f                    l
ae :          f                   l
Æ :    f                    l
æ :          f                   l
Ordinal       : Is AE or ae the same as Æ or æ?
AE :    b
ae :          b
Æ :                         b
æ :                              b
IgnoreCase    : Is AE or ae the same as Æ or æ?
AE :    f                         l
ae :    f                         l
Æ :    f                         l
æ :    f                         l

No options    : Is U" or u" the same as Ü or ü?
U" :    f                    l
u" :          f                   l
Ü :    f                    l
ü :          f                   l
Ordinal       : Is U" or u" the same as Ü or ü?
U" :    b
u" :          b
Ü :                         b
ü :                              b
IgnoreCase    : Is U" or u" the same as Ü or ü?
U" :    f                         l
u" :    f                         l
Ü :    f                         l
ü :    f                         l

示例10: Example

' 导入命名空间
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim ci As CompareInfo = CultureInfo.CurrentCulture.CompareInfo
      
      Dim softHyphen As Char = ChrW(&h00AD)
      
      Dim s1 As String = "ani" + softHyphen + "mal"
      Dim s2 As String = "animal"
      
      ' Find the last index of the soft hyphen using culture-sensitive comparison.
      Console.WriteLine(ci.LastIndexOf(s1, softHyphen, CompareOptions.IgnoreCase))
      Console.WriteLine(ci.LastIndexOf(s2, softHyphen, CompareOptions.IgnoreCase))
      
      ' Find the last index of the soft hyphen using ordinal comparison.
      Console.WriteLine(ci.LastIndexOf(s1, softHyphen, CompareOptions.Ordinal))
      Console.WriteLine(ci.LastIndexOf(s2, softHyphen, CompareOptions.Ordinal))
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Globalization,代码行数:21,代码来源:CompareInfo.LastIndexOf

输出:

6
5
3
-1

示例11: Example

' 导入命名空间
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim ci As CompareInfo = CultureInfo.CurrentCulture.CompareInfo
      
      Dim softHyphen As String = ChrW(&h00AD)
      Dim s1 As String = "ani" + softHyphen + "mal"
      Dim s2 As String = "animal"
      
      Console.WriteLine("Culture-sensitive comparison:")
      ' Use culture-sensitive comparison to find the last soft hyphen.
      Console.WriteLine(ci.LastIndexOf(s1, softHyphen, CompareOptions.None))
      Console.WriteLine(ci.LastIndexOf(s2, softHyphen, CompareOptions.None))
      
      ' Use culture-sensitive comparison to find the last soft hyphen followed by "n".
      Console.WriteLine(ci.LastIndexOf(s1, softHyphen + "n", CompareOptions.None))
      Console.WriteLine(ci.LastIndexOf(s2, softHyphen + "n", CompareOptions.None))
      
      ' Use culture-sensitive comparison to find the last soft hyphen followed by "m".
      Console.WriteLine(ci.LastIndexOf(s1, softHyphen + "m", CompareOptions.None))
      Console.WriteLine(ci.LastIndexOf(s2, softHyphen + "m", CompareOptions.None))
      
      Console.WriteLine("Ordinal comparison:")
      ' Use ordinal comparison to find the last soft hyphen.
      Console.WriteLine(ci.LastIndexOf(s1, softHyphen, CompareOptions.Ordinal))
      Console.WriteLine(ci.LastIndexOf(s2, softHyphen, CompareOptions.Ordinal))
      
      ' Use ordinal comparison to find the last soft hyphen followed by "n".
      Console.WriteLine(ci.LastIndexOf(s1, softHyphen + "n", CompareOptions.Ordinal))
      Console.WriteLine(ci.LastIndexOf(s2, softHyphen + "n", CompareOptions.Ordinal))
      
      ' Use ordinal comparison to find the last soft hyphen followed by "m".
      Console.WriteLine(ci.LastIndexOf(s1, softHyphen + "m", CompareOptions.Ordinal))
      Console.WriteLine(ci.LastIndexOf(s2, softHyphen + "m", CompareOptions.Ordinal))
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Globalization,代码行数:38,代码来源:CompareInfo.LastIndexOf

输出:

6
5
1
1
4
3
Ordinal comparison:
3
-1
-1
-1
3
-1

示例12: Example

' 导入命名空间
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim ci As CompareInfo = CultureInfo.CurrentCulture.CompareInfo
      
      Dim position As Integer
      Dim softHyphen As Char = ChrW(&h00AD)
      Dim s1 As String = "ani" + softHyphen + "mal"
      Dim s2 As String = "animal"
      
      ' Find the last index of the soft hyphen.
      position = ci.LastIndexOf(s1, "m"c)
      Console.WriteLine("'m' at position {0}", position)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s1, softHyphen, position))
      End If
      
      position = ci.LastIndexOf(s2, "m"c)
      Console.WriteLine("'m' at position {0}", position)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s2, softHyphen, position))
      End If   
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Globalization,代码行数:26,代码来源:CompareInfo.LastIndexOf

输出:

m' at position 4
4
m' at position 3
3

示例13: Example

' 导入命名空间
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim ci As CompareInfo = CultureInfo.CurrentCulture.CompareInfo
      
      Dim softHyphen As String = ChrW(&h00AD)
      Dim s1 As String = "ani" + softHyphen + "mal"
      Dim s2 As String = "animal"
      
      ' Find the index of the last soft hyphen.
      Console.WriteLine(ci.LastIndexOf(s1, softHyphen))
      Console.WriteLine(ci.LastIndexOf(s2, softHyphen))
      
      ' Find the index of the last soft hyphen followed by "n".
      Console.WriteLine(ci.LastIndexOf(s1, softHyphen + "n"))
      Console.WriteLine(ci.LastIndexOf(s2, softHyphen + "n"))
      
      ' Find the index of the last soft hyphen followed by "m".
      Console.WriteLine(ci.LastIndexOf(s1, softHyphen + "m"))
      Console.WriteLine(ci.LastIndexOf(s2, softHyphen + "m"))
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Globalization,代码行数:24,代码来源:CompareInfo.LastIndexOf

输出:

6
5
1
1
4
3

示例14: Example

' 导入命名空间
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim ci As CompareInfo = CultureInfo.CurrentCulture.CompareInfo
      
      Dim softHyphen As Char = ChrW(&h00AD)
      
      Dim s1 As String = "ani" + softHyphen + "mal"
      Dim s2 As String = "animal"
      
      ' Find the index of the last soft hyphen.
      Console.WriteLine(ci.LastIndexOf(s1, softHyphen))
      Console.WriteLine(ci.LastIndexOf(s2, softHyphen))
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Globalization,代码行数:17,代码来源:CompareInfo.LastIndexOf

输出:

6
5

示例15: Example

' 导入命名空间
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim ci As CompareInfo = CultureInfo.CurrentCulture.CompareInfo
      
      Dim position As Integer
      Dim softHyphen As String = ChrW(&h00AD)
      
      Dim s1 As String = "ani" + softHyphen + "mal"
      Dim s2 As String = "animal"
      
      ' Find the index of the soft hyphen.
      position = ci.LastIndexOf(s1, "m")
      Console.WriteLine("'m' at position {0}", position)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s1, softHyphen, position))
      End If
         
      position = ci.LastIndexOf(s2, "m")
      Console.WriteLine("'m' at position {0}", position)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s2, softHyphen, position))
      End If
      
      ' Find the index of the soft hyphen followed by "n".
      position = ci.LastIndexOf(s1, "m")
      Console.WriteLine("'m' at position {0}", position)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s1, softHyphen + "n", position))
      End If
         
      position = ci.LastIndexOf(s2, "m")
      Console.WriteLine("'m' at position {0}", position)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s2, softHyphen + "n", position))
      End If
      
      ' Find the index of the soft hyphen followed by "m".
      position = ci.LastIndexOf(s1, "m")
      Console.WriteLine("'m' at position {0}", position)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s1, softHyphen + "m", position))
      End If
      
      position = ci.LastIndexOf(s2, "m")
      Console.WriteLine("'m' at position {0}", position)
      If position >= 0 Then
         Console.WriteLine(ci.LastIndexOf(s2, softHyphen + "m", position))
      End If
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Globalization,代码行数:53,代码来源:CompareInfo.LastIndexOf

输出:

m' at position 4
4
m' at position 3
3
m' at position 4
1
m' at position 3
1
m' at position 4
4
m' at position 3
3


注:本文中的System.Globalization.CompareInfo.LastIndexOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。