Long strings in Visual Basic 2008


I suspect everyone already knew this – but for me it was shiny and new 🙂 XML Literals do not require line continuation characters, hence rather than this:

   1: Dim msg1 As String = "this is a " & _
   2:                     "really, " & _
   3:                     "really " & _
   4:                     "long string"

you can create a really long string using an XML Literal:

   1: Dim msg1 = <s>This is a
   2:                 really,
   3:                 really
   4:                 long string</s>.Value

Note: the whitespace is maintained.

Skip to main content