问题描述
虽然我正在学习格式,但它是否可以使用字符串?
我想取这个字符串
dim thisCustNo as string =" ; 9128764526"
并让它看起来像
(912)876-4526
我发现我能做到这一点
thisCustNo.Format("({0}){1} - {2}",thisCustNo.Substring(0,3),thisCustNo.Substrin g(3,3),thisCustNo.Substring( 6,4))
"(" + thisCustNo.Substring()更简单,更清晰或更好。 0,3)+")" + thisCustNo.Subst ring(3,3)+" - " + thisCustNo.Substring(6,4)
我错过了什么?
While I''m learning about format, will it work with strings?
I want to take this string
dim thisCustNo as string = "9128764526"
and make it look like
(912)876-4526
I found I can do this
thisCustNo.Format("({0}){1}-{2}",thisCustNo.Substring(0,3),thisCustNo.Substrin g(3,3),thisCustNo.Substring(6,4))
But for me that isn''t a bit easier or clearer or nicer than
"("+thisCustNo.Substring(0,3)+")"+thisCustNo.Subst ring(3,3)+"-"+thisCustNo.Substring(6,4)
Am I missing something?
推荐答案
这篇关于格式化文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!