English 中文(简体)
• 如何在C#的插图中轻易展示双重引语?
原标题:How to easily display double quotes in strings in C#?
  • 时间:2009-10-20 13:26:26
  •  标签:

如果你有无数的双重引言,

在公共卫生和社会福利部,你可以这样做:

file.WriteLine( <controls:FormField Name="Strasse" LabelText="Strasse"> );

页: 1 页: 1

file.WriteLine("<controls:FormField Name="Strasse" LabelText="Strasse">");

C#中是否有办法在PHP上做你可以做的事,例如你可以做的“......”:......,这样你就不需要双重鞭??

www.un.org/Depts/DGACM/index_spanish.htm 感谢Fredrik,这在“Sting”中甚至引人引用和曲解。 格式可读:

    file.WriteLine(String.Format(@"<TextBox Text=""{{Binding {0}}}""
 Style=""{{DynamicResource FormularFieldTextBox}}""/>", fieldName));
最佳回答

C# string有两种表述方式:

file.WriteLine("<controls:FormField Name="Strasse" LabelText="Strasse">");
file.WriteLine(@"<controls:FormField Name=""Strasse"" LabelText=""Strasse"">");
问题回答
"<controls:FormField Name= Strasse  LabelText= Strasse >".Replace(" ", """)

而这是唯一的选择。

或“@””

我建议避免采取类似做法:

const char doubleQuote =  " ;

Console.WriteLine("<controls:FormField Name={0}Strasse{0} LabelText={0}Strasse{0}>", doubleQuote);

I would recommend using a resource file to store the string constants. This increases elegance and code readability. Also, quotes and special characters can be displayed without messing around with too many escape sequences.

你们可以像现在这样创建资源档案。

String Name(Key) => FormFieldControl
Value => <controls:FormField Name="{0}" LabelText="{1}">

这一点可以在像法典这样的法典中使用。

const string fieldName = "Strasse";
Console.WriteLine(ResourceFile.FormFieldControl, fieldName, fieldName);




相关问题
热门标签