HOW CAN I FORMAT A STRING?

marcel ethan

Total Post:105

Points:735
Posted by  marcel ethan
C# 
C#
 946  View(s)
Ratings:
Rate this:

My string looks like 0145655789, I want to change its format to 0145.655.789

This is the code I tried:

enterpriseCode.Append(String.Format("{0:####.###.###}", aNum.ToString()).Replace(";", ""));

But it giving me same string, not giving me desired string.

How to do it?

  1. Pravesh Singh

    Post:412

    Points:2888
    Re: How can I format a string?

    Hi marcel,

    You can try this:-

    string formatted = enterpriseCode.Insert(4, ".").Insert(8, ".");

    Hope this will solve your problem.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!