'How to custom 'format' an int in ASP.NET MVC Core?

I have a primary key AccountNumber which is INT. I want it to be displayed in my View like this: 123-456-78. How can I add '-' character between the numbers?

Thanks!



Solution 1:[1]

you can put in your view this code

<div> @Model.AccountNumber.ToString("000-000-00")  </div>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Serge