实现这一目标的专业方法是什么? 谢谢. 我已经无耻地从 this question中删除了示例并将其从C#转换为VB.net. Public Function GetNthIndex(s As String, t As Char, n As Integer) As Integer Dim count As Integer = 0
谢谢.
我已经无耻地从 this question中删除了示例并将其从C#转换为VB.net.Public Function GetNthIndex(s As String, t As Char, n As Integer) As Integer Dim count As Integer = 0 For i As Integer = 0 To s.Length - 1 If s(i) = t Then count += 1 If count = n Then Return i End If End If Next Return -1 End Function