我想从字符串中获取最后5位数/字符.例如,从中"I will be going to school in 2011!",我想得到"2011!".
有任何想法吗?我知道Visual Basic有Right(string, 5); 这对我没用,给了我一个错误.
dcp*_*dcp 56
str.Substring(str.Length - 5)
Run Code Online (Sandbox Code Playgroud)
Gle*_*lar 25
错误检查:
result = str.Substring(Math.Max(0, str.Length - 5))
Run Code Online (Sandbox Code Playgroud)
检查错误:
Dim result As String = str
If str.Length > 5 Then
result = str.Substring(str.Length - 5)
End If
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
148784 次 |
| 最近记录: |