有一封電子郵件,想要從中刪除第一個「@」符號,然後確保它在第二次檢查時沒有多於一個。這是目前我正在做的事情。從字符串中刪除「@」
Dim tempEmail As String = ContactEmail
Dim count As Integer = 0
If tempEmail.IndexOf("@") <> -1 Then 'check for one
count += 1
tempEmail.Remove(tempEmail.IndexOf("@"), 1)
End If
If tempEmail.IndexOf("@") <> -1 Then 'check for two
count += 1
End If
If count = 1 Then
JustifyString(ContactEmail, 66, " ", LEFT_JUSTIFY)
Else
ContactEmail = BLANK_EMAIL
End If
但調試後,我發現它實際上從不會從tempEmail的字符串中刪除「@」符號。爲什麼?
哦gotcha。這在Java中有什麼不同?我記得能夠在那裏做類似的事情。 – Scott 2010-07-29 13:37:37
不正常,我不認爲。例如,'trim()'方法返回一個新的String,它不會改變它被調用的那個... – Stephen 2010-07-29 13:41:07