troubleshooting Question

parse a string to result in a specific format

Avatar of solraccheffy
solraccheffy asked on
6 Comments1 Solution219 ViewsLast Modified:
I need to format this string...
Its in the code behind of a c# web app.
The string must always end up in the form of ##/##/####
Which is...2 numbers/2 numbers/4 numbers...
So I need to parse the string and if any of the 3 values are not the appropriate amount of digits, it needs to be preceeded with a zero, see below.
5/3/2341 should be 05/05/2341
12/2/1222 should be 12/01/1222
12/12/11 should be 12/12/0011

there should always be 2 digits/ 2 digits/ 4 digits
So I need to parse this string called valNumber to end up in this format. I know I need to use substring and some other methods but need the most effective way.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros