In C# posso utilizzare:come scrivere un grande stringa di linea in F #
string myBigString = @"
<someXmlForInstance>
<someChild />
</someXmlForInstance>
";
come fare questo in F #?
In C# posso utilizzare:come scrivere un grande stringa di linea in F #
string myBigString = @"
<someXmlForInstance>
<someChild />
</someXmlForInstance>
";
come fare questo in F #?
In F # 3.0, VS 2012, il supporto è stato aggiunto per triple-quoted strings.
In una stringa tripla citato, tutto tra triple virgolette ("" "... """) è mantenuta testualmente; non c'è modo di sfuggire. Di conseguenza, se voglio avere un po 'di XAML come una stringa letterale, è facile:
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>"""
Se preceduto dal simbolo @, il letterale è una stringa letterale. Ciò significa che tutte le sequenze di escape vengono ignorate, tranne che due caratteri di virgolette vengono interpretati come un carattere di virgolette.
Fonte: Strings (F#)
provare solo:
let str1 = "abc
def"
let str2 = "abc\
def"
Per ulteriori informazioni si veda: http://msdn.microsoft.com/en-us/library/362314fe.aspx