Sacramento Software Development

C# Verbatim Strings

Posted by John Lockwood on June 29th, 2006

Just doing a bit of hacking with the C Sharp mono compiler this evening. (I’m waiting for Visual Studio to ship — what else?). Meantime I may have found my first error in Donis Marshall’s Programming Microsoft Visual C# 2005: The Language — which doesn’t bode incredibly well given that I’m only on page 23 or so.

Looking at verbatim strings, Marshall neglects to point out that to escape a string inside a verbatim string you use double quotes, not backslash quote.

Here’s a braindead example of the right way to do it. Mono users use mcs VerbatimString.cs to compile.


using System;
using System.Text;

public class VerbatimStrings
{
public static void Main()
{
String verbatim =

@"This is a
verbatim string, and it can go
on and on, using ""quote"" characters
etc but everything else
is not escaped, like tab characters, \t
and so forth."

System.Console.Write(verbatim);
}
}

You know, it took about three times as long to write the blog post as it did to figure it out to begin with. I love trying to write code in HTML. There should be a wordpress plugin or the like for that…

Posted in Random Particles, Software | Add a comment »

.NET Contract in Sacramento Going Well

Posted by John Lockwood on June 28th, 2006

Posted in Random Particles, Software | Add a comment »

ASP.NET 2.0 Programming: Hooray, New Gig!

Posted by John Lockwood on June 24th, 2006

Posted in Random Particles, Software | Add a comment »

Saying Goodbye to the Legacy Stuff

Posted by John Lockwood on June 19th, 2006

Posted in Miscellaneous | Add a comment »

Using Ant and XDoclet with JDO

Posted by John Lockwood on June 3rd, 2006

Posted in Software | Add a comment »


Subscribe Using RSS