If you have a string with a numerous double quotes,
in PHP you can do this:
file.WriteLine('<controls:FormField Name="Strasse" LabelText="Strasse">');
in C# you have to do this:
file.WriteLine("<controls:FormField Name=\"Strasse\" LabelText=\"Strasse\">");
Is there a way in C# to do what you can do above in PHP, something like the @"c:\temp" which you can do so that you don't need double slashes?
Thanks Fredrik, that makes even quotes and curly brackets in a String.Format fairly readable:
file.WriteLine(String.Format(@"<TextBox Text=""{{Binding {0}}}""
Style=""{{DynamicResource FormularFieldTextBox}}""/>", fieldName));
'\' is the escape sequence that is used to insert a double quote. Below we can see that we are using this escape sequence inside our string, and the output shows the string with quotations.
\" - escape sequence Since printf uses ""(double quotes) to identify starting and ending point of a message, we need to use \" escape sequence to print the double quotes.
There are two ways to represent quotes in C# strings:
file.WriteLine("<controls:FormField Name=\"Strasse\" LabelText=\"Strasse\">");
file.WriteLine(@"<controls:FormField Name=""Strasse"" LabelText=""Strasse"">");
"<controls:FormField Name='Strasse' LabelText='Strasse'>".Replace("'", "\"")
Which isn't great, but about the only option.
Or @"""" insted of \" you can use ""
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With