gpt4 book ai didi

.net - 如何在 F# 中编写内联大字符串

转载 作者:行者123 更新时间:2023-12-04 00:52:59 26 4
gpt4 key购买 nike

在 C# 中,我可以使用:

string myBigString = @"

<someXmlForInstance>
<someChild />
</someXmlForInstance>

";

如何在 F# 中做到这一点?

最佳答案

在 F# 3.0、VS 2012 中,添加了对 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>"""

关于.net - 如何在 F# 中编写内联大字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11757699/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com