ojek
ojek

Reputation: 10068

Data annotations - DisplayFormat - formatting string of numbers

I have the following string: "10222002750400447092095835"

I want it to be displayed like this: 10 2220 0275 0400 4470 9209 5835

I tried doing the following, with no result at all:

[DisplayFormat(DataFormatString = "{0:00 0000 0000 0000 0000 0000 0000}", ApplyFormatInEditMode = true)]

or

[DisplayFormat(DataFormatString = "{0:## #### #### #### #### #### ####}", ApplyFormatInEditMode = true)]

What am I doing wrong?

Upvotes: 3

Views: 11054

Answers (1)

James Shaw
James Shaw

Reputation: 839

I believe what you are looking for is String masking. See below.

Stackoverflow - How to mask a string Stackoverflow - Apply mask to string

Upvotes: 1

Related Questions