Special VB String Escape Character like @’String’ in C#

Due to my sins (it would seem) I still have to work with VB.net from time to time.  But I am so used to doing this:

string format = @"bunch of html that can split over lines and have {0,1,2,...,n} to format the html with data";
for(int ii = 0; ii < list.Count; ii++)
{
output += string.format(format, [bits]);
}

(or any other shape and form you care to loop, don’t care…).  But VB.net doesn’t have the @”” string literal thingy (cabbage?).  But it does have this:

Dim format As String = <![CDATA[<div class="item">
                                    <a>{0}</a>
                                    <p>{1}</p>
                           </div> ]]>.Value

Which is nice.  Hope that helps you all out.  Helped me.

Leave a Reply

Your email address will not be published.