2012-08-01 5 views

risposta

13

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>""" 
1

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#)