Archive for March, 2012
C#: Escape Double-quote within a String
Posted by Tim Valentine in General on March 21, 2012
Problem
When you need to add a double-quote character to a string, you will run into a problem. Double-quotes are the delimiters for the beginning and end of a string, so placing a double-quote within a string will confuse the compiler and it will give you an exception.
Solution
C#: Escape Curly Braces within Formatted String
Posted by Tim Valentine in General on March 21, 2012
Problem
When passing in a formatted string as an argument to a method such as Console.WriteLine, String.Format, etc., curly braces have a special meaning. They are used as a placeholder for a variable. Therefore when you want to add a curly brace within the formatted string, but you don’t want it to be interpreted as a placeholder for a variable, you have a problem.