Pages

Friday, September 25, 2009

Text Formatting made Easy in ASP.NET

In one of my project there was an requirement to display the Phone Numbers formatted according to US Standards(eg: 123-456-7890).

I initially thought I have to insert the '-' symbol at the index values. But my goodness, this was made so easy in .Net String Formatting.

For Example:

Dim phone as Integer = 123456890

String.Format("{0:###-###-####}", phone)


This will be displayed as 123-456-7890

Be a smart coder. Let me know if its useful. Happy Coding.

No comments:

Post a Comment