获取字符串的最后 5 个字符 [英] Get last 5 characters in a string
本文介绍了获取字符串的最后 5 个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从字符串中获取最后 5 位数字/字符.例如,从 "I will go to school in 2011!"
,我想得到 "2011!"
.
I want to get the last 5 digits/characters from a string. For example, from "I will be going to school in 2011!"
, I would like to get "2011!"
.
有什么想法吗?我知道 Visual Basic 有 Right(string, 5)
;这对我不起作用,并给了我一个错误.
Any ideas? I know Visual Basic has Right(string, 5)
; this didn't work for me and gave me an error.
推荐答案
str.Substring(str.Length - 5)
这篇关于获取字符串的最后 5 个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文