[英]Razor code EditorFor showing '�' as default?
In my Form, there is a textbox, in razor code using EditorFor and the type given for this is Char .在我的表单中,有一个文本框,在 razor 代码中使用 EditorFor ,为此给出的类型是Char 。 But it always shows a '�' as default, what's that mean?
但它总是默认显示一个“...”,这是什么意思? is this because of char type?
这是因为char类型吗?
This � is the invalid unicode code point glyph.这是无效的 unicode 代码点字形。 It is what you will see in most browsers when they encounter the null character '\0' (U+0000).
这是您在大多数浏览器中遇到 null 字符 '\0' (U+0000) 时会看到的内容。 This happens to be the default value of the .NET
char
data type.这恰好是 .NET
char
数据类型的默认值。
Three workarounds:三种解决方法:
c == default(char)? ' ': c
c == default(char)? ' ': c
c == default(char)? ' ': c
EditorFor
or LabelFor
when the value is default(char)
default(char)
时隐藏EditorFor
或LabelFor
System.String
, which leads to correct rendition in both cases null
and String.Empty
System.String
,这在null
和String.Empty
两种情况下都会导致正确的再现
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.