In following example I would like to Trancate first 5 digits and last 3 digits.
W04056040-PAY001
So I can get 6040-PAY
Any code behind examples?
Any help will be appriciated.
Thanks.
TekinUse the stringbuilder class (remove method):
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtextstringbuildermemberstopic.asp
Or if you want to do it old school, the intrinsic Mid function works well too.
Hi mtekin303,
There's many ways to solve this problem. Here's two ideas:
[Visual Basic]
Dim temp As String = "W04056040-PAY001"
Response.Write("Sample 1: " + temp.Substring(5,8) + "<br />")
Response.Write("Sample 2: " + temp.Remove(temp.Length-3,3).Remove(0,5))[C#]
string temp = "W04056040-PAY001";
Response.Write("Sample 1: " + temp.Substring(5,8) + "<br />");
Response.Write("Sample 2: " + temp.Remove(temp.Length-3,3).Remove(0,5));
Hope this helps.
Thank you.
Stringbuilder resolved it.
Thanks again.
Thanks Chuck.
Stringbuilder resolved it.
0 comments:
Post a Comment