String.Index和String.Remove的又一个例子

如何查找指定字符在字符串中位置,又一个例子:

假定StrSuperUser = "[email protected];julia.wong.advantech.com.tw",通过StrSuperUser.IndexOf([email protected]),返回0,StrSuperUser.Remove(int startIndex,int count), startIndex 为开始删除字符的位置。count 为要删除的字符数。

假定StrSuperUser="[email protected]", StrSuperUser.Remove(0,count),返回为""。

 

                        Dim loc As Integer = StrSuperUser.IndexOf("[email protected]", StringComparison.OrdinalIgnoreCase)

                        Dim count As Integer = "[email protected]".Length()

                        If StrSuperUser.Length > count Then count = count + 1 'if more than 1 email, remove ;

                        StrSuperUser = StrSuperUser.Remove(loc, count)

 

你可能感兴趣的:(String)