Reputation: 17969
In C# I can use:
string myBigString = @"
<someXmlForInstance>
<someChild />
</someXmlForInstance>
";
How to do this in F#?
Upvotes: 14
Views: 2071
Reputation: 28764
In F# 3.0, VS 2012, support was added for triple-quoted strings.
In a triple-quoted string, everything between triple-quotes ("""...""") is kept verbatim; there is no escaping at all. As a result, if I want to have a bit of XAML as a string literal, it’s easy:
let xaml = """
<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Name="mainPanel">
<Border BorderThickness="15.0" BorderBrush="Black">
<StackPanel Name="stackPanel1">
<TextBlock Text="Super BreakAway!" FontSize="24" HorizontalAlignment="Center" />
<TextBlock Text="written in F#, by Brian McNamara - press 'p' to pause"
FontSize="12" HorizontalAlignment="Center" />
<Border BorderThickness="2.0" BorderBrush="Black">
<Canvas Name="canvas" Background="White" />
</Border>
</StackPanel>
</Border>
</StackPanel>"""
Upvotes: 16
Reputation: 7931
Try just :
let str1 = "abc
def"
let str2 = "abc\
def"
For more information see: http://msdn.microsoft.com/en-us/library/362314fe.aspx
Upvotes: 1
Reputation: 10222
If preceded by the @ symbol, the literal is a verbatim string. This means that any escape sequences are ignored, except that two quotation mark characters are interpreted as one quotation mark character.
Source: Strings (F#)
Upvotes: 2