我正在使用 MVC,在我的班级中,我有一个成员,其描述中有双引号,如下所示:
[Display(Name = "Biological "Parent"?")]
public bool? IsParent { get; set; }
我们有什么方法可以使用上述方法在剃刀视图中显示双引号,还是我必须用我想要的内容声明标签?
我尝试将 (
"
) 替换为 ("
),它在渲染时仅在标签文本中显示“Biological "Parent"
”
只需转义 C# 中的双引号即可:
[Display(Name = "Biological \"Parent\"?")]
public bool? IsParent { get; set; }
或
[Display(Name = @"Biological ""Parent""?")]
public bool? IsParent { get; set; }