c# - 数据注释 - DisplayFormat - 格式化数字字符串

标签 c# asp.net-mvc asp.net-mvc-3 entity-framework data-annotations

我有以下字符串:"10222002750400447092095835"

我希望它像这样显示:10 2220 0275 0400 4470 9209 5835

我尝试了以下操作,但没有任何结果:

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

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

我做错了什么?

最佳答案

我相信您正在寻找的是字符串屏蔽。见下文。

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

关于c# - 数据注释 - DisplayFormat - 格式化数字字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14759582/

相关文章:

c# - Visual Studio 无可用源

jquery - Asp.Net MVC3 具有必需的字段验证

jquery - 第二次调用对话框后,Telerik DropDownList 在 JQuery 对话框中被禁用

c# - 如何编写最小起订量测试来设置返回计数值的方法

c# - 将 linq 查询连接到 View 模型的结果

.net - 伪造 Entity Framework 4.1 的 DbContext 进行测试

jquery - 客户端验证不适用于重用和嵌套的复杂属性

c# - FTP 上传失败 'The underlying connection was closed: An unexpected error occurred on a receive.'

c# - 跳过 Aero 窗口动画

c# - 在不创建类的情况下反序列化 JSON 响应