我想从字符串中获取最后5个数字/字符。例如,我想从"I will be going to school in 2011!"
获取"2011!"
。
有什么想法吗?我知道Visual Basic有Right(string, 5)
;这对我不起作用,并给了我一个错误。
发布于 2010-05-12 02:47:37
str.Substring(str.Length - 5)
发布于 2010-05-12 02:52:49
错误检查:
result = str.Substring(Math.Max(0, str.Length - 5))
发布于 2010-05-12 02:51:38
检查错误:
Dim result As String = str
If str.Length > 5 Then
result = str.Substring(str.Length - 5)
End If
https://stackoverflow.com/questions/2813505
复制相似问题