Skip to content

Commit b023646

Browse files
authored
PlatformID F# snippet (#7821)
1 parent e37e20f commit b023646

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net6.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<Compile Include="pid.fs" />
9+
</ItemGroup>
10+
</Project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//<snippet1>
2+
// This example demonstrates the PlatformID enumeration.
3+
open System
4+
5+
let msg1 = "This is a Windows operating system."
6+
let msg2 = "This is a Unix operating system."
7+
let msg3 = "ERROR: This platform identifier is invalid."
8+
9+
// Assume this example is run on a Windows operating system.
10+
let os = Environment.OSVersion
11+
let pid = os.Platform
12+
match pid with
13+
| PlatformID.Win32NT
14+
| PlatformID.Win32S
15+
| PlatformID.Win32Windows
16+
| PlatformID.WinCE ->
17+
printfn $"{msg1}"
18+
| PlatformID.Unix ->
19+
printfn $"{msg2}"
20+
| _ ->
21+
printfn $"{msg3}"
22+
// This example produces the following results:
23+
// This is a Windows operating system.
24+
//</snippet1>

xml/System/PlatformID.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
6767
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/platformID.class/CPP/pid.cpp" id="Snippet1":::
6868
:::code language="csharp" source="~/snippets/csharp/System/PlatformID/Overview/pid.cs" id="Snippet1":::
69+
:::code language="fsharp" source="~/snippets/fsharp/System/PlatformID/Overview/pid.fs" id="Snippet1":::
6970
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/platformID.class/VB/pid.vb" id="Snippet1":::
7071
7172
]]></format>

0 commit comments

Comments
 (0)