Branislav Živanović
Branislav Živanović

Reputation: 17

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!

Upvotes: 1

Views: 162

Answers (1)

Serge
Serge

Reputation: 43959

you can put in your view this code

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

Upvotes: 1

Related Questions