From f6af3fc5534faa1ec91b13249673730bdf5cc5e3 Mon Sep 17 00:00:00 2001 From: albert-du <52804499+albert-du@users.noreply.github.com> Date: Tue, 28 Dec 2021 14:10:51 -0800 Subject: [PATCH 1/3] System.Console F# snippets --- .../Console-EXPANDTABSEX/FS/expandtabsex.fs | 37 +++++++ .../Console-EXPANDTABSEX/FS/fs.fsproj | 9 ++ .../VS_Snippets_CLR/console.beep/FS/beep.fs | 35 +++++++ .../VS_Snippets_CLR/console.beep/FS/fs.fsproj | 9 ++ .../VS_Snippets_CLR/console.beep2/FS/b2.fs | 68 +++++++++++++ .../console.beep2/FS/fs.fsproj | 9 ++ .../console.bufferHW/FS/fs.fsproj | 9 ++ .../VS_Snippets_CLR/console.bufferHW/FS/hw.fs | 13 +++ .../console.cancelkeypress/fs/ckp.fs | 57 +++++++++++ .../console.cancelkeypress/fs/fs.fsproj | 9 ++ .../console.cursorLTS/FS/fs.fsproj | 9 ++ .../console.cursorLTS/FS/lts.fs | 59 +++++++++++ .../console.cursorsize/FS/csize.fs | 33 +++++++ .../console.cursorsize/FS/fs.fsproj | 9 ++ .../console.cursorvis/FS/fs.fsproj | 9 ++ .../console.cursorvis/FS/vis.fs | 63 ++++++++++++ .../console.keyavailable/FS/fs.fsproj | 9 ++ .../console.keyavailable/FS/ka.fs | 36 +++++++ .../VS_Snippets_CLR/console.read/FS/fs.fsproj | 9 ++ .../VS_Snippets_CLR/console.read/FS/read.fs | 68 +++++++++++++ .../console.readkey1/FS/fs.fsproj | 9 ++ .../VS_Snippets_CLR/console.readkey1/FS/rk.fs | 34 +++++++ .../console.readkey2/FS/fs.fsproj | 9 ++ .../console.readkey2/FS/rkbool.fs | 33 +++++++ .../console.setwindowsize/FS/fs.fsproj | 9 ++ .../console.setwindowsize/FS/sws.fs | 41 ++++++++ .../console.title/FS/fs.fsproj | 9 ++ .../console.title/FS/mytitle.fs | 21 ++++ .../console.windowLT/FS/fs.fsproj | 9 ++ .../console.writelineFmt1/fs/fs.fsproj | 9 ++ .../console.writelineFmt1/fs/wl.fs | 99 +++++++++++++++++++ .../VS_Snippets_CLR/consolein/FS/consolein.fs | 13 +++ .../VS_Snippets_CLR/consolein/FS/fs.fsproj | 9 ++ .../System.Console.ReadKey/fs/ReadKey1.fs | 18 ++++ .../System.Console.ReadKey/fs/ReadKey2.fs | 18 ++++ .../System.Console.ReadKey/fs/fs.fsproj | 10 ++ .../system.Console-INSERTTABS/FS/fs.fsproj | 9 ++ .../FS/inserttabs.fs | 55 +++++++++++ .../system.Console-REFORMAT/FS/fs.fsproj | 9 ++ .../system.Console-REFORMAT/FS/reformat.fs | 52 ++++++++++ .../FS/decode.fs | 14 +++ .../FS/fs.fsproj | 9 ++ .../system.Console.ReadLine/fs/ReadLine2.fs | 27 +++++ .../system.Console.ReadLine/fs/ReadLine3.fs | 31 ++++++ .../fs/ReadLineSimple.fs | 19 ++++ .../system.Console.ReadLine/fs/fs.fsproj | 11 +++ .../system.Console.SetError/fs/SetError1.fs | 32 ++++++ .../system.Console.SetError/fs/fs.fsproj | 9 ++ .../system.Console.WriteLine/FS/WriteLine6.fs | 19 ++++ .../system.Console.WriteLine/FS/WriteLine7.fs | 8 ++ .../system.Console.WriteLine/FS/fs.fsproj | 14 +++ .../system.Console.WriteLine/FS/newline1.fs | 39 ++++++++ .../system.Console.WriteLine/FS/tipcalc.fs | 30 ++++++ .../FS/writeline_boolean1.fs | 19 ++++ .../FS/writeline_obj1.fs | 19 ++++ .../fs/backgroundcolor1.fs | 21 ++++ .../fs/fs.fsproj | 9 ++ .../system.console.class.unsafe/fs/fs.fsproj | 9 ++ .../system.console.class/fs/fs.fsproj | 12 +++ .../system.console.clear/fs/clear1.fs | 67 +++++++++++++ .../system.console.clear/fs/fs.fsproj | 9 ++ .../system.console.error/fs/error1.fs | 31 ++++++ .../system.console.error/fs/fs.fsproj | 9 ++ .../fs/fs.fsproj | 9 ++ .../fs/viewtextfile.fs | 43 ++++++++ .../system.console.out/fs/fs.fsproj | 9 ++ .../system.console.out/fs/out1.fs | 32 ++++++ .../system.console.setout/fs/fs.fsproj | 9 ++ .../system.console.setout/fs/source.fs | 17 ++++ .../system.console.windowleft/fs/fs.fsproj | 9 ++ .../fs/windowleft1.fs | 36 +++++++ .../system.console.write/fs/WriteParams1.fs | 35 +++++++ .../system.console.write/fs/WriteParams2.fs | 34 +++++++ .../system.console.write/fs/fs.fsproj | 10 ++ .../system.consolecolor/fs/Example2.fs | 11 +++ .../fs/foregroundcolor3.fs | 74 ++++++++++++++ .../system.consolecolor/fs/fs.fsproj | 10 ++ xml/System/Console.xml | 85 ++++++++++++++++ 78 files changed, 1924 insertions(+) create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/Console-EXPANDTABSEX/FS/expandtabsex.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/Console-EXPANDTABSEX/FS/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.beep/FS/beep.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.beep/FS/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.beep2/FS/b2.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.beep2/FS/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.bufferHW/FS/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.bufferHW/FS/hw.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.cancelkeypress/fs/ckp.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.cancelkeypress/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.cursorLTS/FS/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.cursorLTS/FS/lts.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.cursorsize/FS/csize.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.cursorsize/FS/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.cursorvis/FS/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.cursorvis/FS/vis.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.keyavailable/FS/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.keyavailable/FS/ka.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.read/FS/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.read/FS/read.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.readkey1/FS/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.readkey1/FS/rk.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.readkey2/FS/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.readkey2/FS/rkbool.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.setwindowsize/FS/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.setwindowsize/FS/sws.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.title/FS/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.title/FS/mytitle.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.windowLT/FS/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.writelineFmt1/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/console.writelineFmt1/fs/wl.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/consolein/FS/consolein.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/consolein/FS/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/System.Console.ReadKey/fs/ReadKey1.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/System.Console.ReadKey/fs/ReadKey2.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/System.Console.ReadKey/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/FS/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/FS/inserttabs.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.OpenStandartInput/FS/decode.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.OpenStandartInput/FS/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/ReadLine2.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/ReadLine3.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/ReadLineSimple.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.SetError/fs/SetError1.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.SetError/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/WriteLine6.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/WriteLine7.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/newline1.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/tipcalc.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/writeline_boolean1.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/writeline_obj1.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.backgroundcolor/fs/backgroundcolor1.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.backgroundcolor/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class.unsafe/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.clear/fs/clear1.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.clear/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.error/fs/error1.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.error/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.openstandarderror/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.openstandarderror/fs/viewtextfile.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.out/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.out/fs/out1.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.setout/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.setout/fs/source.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.windowleft/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.windowleft/fs/windowleft1.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.write/fs/WriteParams1.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.write/fs/WriteParams2.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.write/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolecolor/fs/Example2.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolecolor/fs/foregroundcolor3.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolecolor/fs/fs.fsproj diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/Console-EXPANDTABSEX/FS/expandtabsex.fs b/samples/snippets/fsharp/VS_Snippets_CLR/Console-EXPANDTABSEX/FS/expandtabsex.fs new file mode 100644 index 00000000000..bb779041b16 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/Console-EXPANDTABSEX/FS/expandtabsex.fs @@ -0,0 +1,37 @@ +// +open System +open System.IO + +let tabSize = 4 +let usageText = "Usage: EXPANDTABSEX inputfile.txt outputfile.txt" + +[] +let main args = + if args.Length < 2 then + printfn $"{usageText}" + else + try + use writer = new StreamWriter(args[1]) + Console.SetOut writer + Console.SetIn(new StreamReader(args[0])) + let mutable i = Console.Read() + while i <> -1 do + let c = char i + if c = '\t' then + Console.WriteLine(("").PadRight(tabSize, ' ')) + else + printf $"{c}" + i <- Console.Read() + // Recover the standard output stream so that a + // completion message can be displayed. + use standardOutput = new StreamWriter(Console.OpenStandardOutput()) + standardOutput.AutoFlush <- true + Console.SetOut standardOutput + printfn $"EXPANDTABSEX has completed the processing of {args[0]}." + with :? IOException as e -> + let errorWriter = Console.Error + errorWriter.WriteLine e.Message + errorWriter.WriteLine usageText + 0 + +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/Console-EXPANDTABSEX/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/Console-EXPANDTABSEX/FS/fs.fsproj new file mode 100644 index 00000000000..bf09dc1c564 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/Console-EXPANDTABSEX/FS/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.beep/FS/beep.fs b/samples/snippets/fsharp/VS_Snippets_CLR/console.beep/FS/beep.fs new file mode 100644 index 00000000000..5e0bd2c6d37 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.beep/FS/beep.fs @@ -0,0 +1,35 @@ +// +// This example demonstrates the Console.Beep() method. +open System + +[] +let main args = + if args.Length = 1 then + match Int32.TryParse args[0] with + | true, x when x >= 1 && x <= 9 -> + for i = 1 to x do + Console.WriteLine $"Beep number {i}." + Console.Beep() + | _ -> + Console.WriteLine "Usage: Enter the number of times (between 1 and 9) to beep." + else + Console.WriteLine "Usage: Enter the number of times (between 1 and 9) to beep." + + 0 + +// This example produces the following results: + +// >beep +// Usage: Enter the number of times (between 1 and 9) to beep + +// >beep 9 +// Beep number 1. +// Beep number 2. +// Beep number 3. +// Beep number 4. +// Beep number 5. +// Beep number 6. +// Beep number 7. +// Beep number 8. +// Beep number 9. +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.beep/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/console.beep/FS/fs.fsproj new file mode 100644 index 00000000000..c9daa19046d --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.beep/FS/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.beep2/FS/b2.fs b/samples/snippets/fsharp/VS_Snippets_CLR/console.beep2/FS/b2.fs new file mode 100644 index 00000000000..4123e3230db --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.beep2/FS/b2.fs @@ -0,0 +1,68 @@ +// +// This example demonstrates the Console.Beep(Int32, Int32) method +open System +open System.Threading + +// Define the frequencies of notes in an octave, as well as +// silence (rest). +type Tone = + | REST = 0 + | GbelowC = 196 + | A = 220 + | Asharp = 233 + | B = 247 + | C = 262 + | Csharp = 277 + | D = 294 + | Dsharp = 311 + | E = 330 + | F = 349 + | Fsharp = 370 + | G = 392 + | Gsharp = 415 + +// Define the duration of a note in units of milliseconds. +type Duration = + | WHOLE = 1600 + | HALF = 800 + | QUARTER = 400 + | EIGHTH = 200 + | SIXTEENTH = 100 + +// Define a note as a frequency (tone) and the amount of +// time (duration) the note plays. +[] +type Note = + { Tone: Tone + Duration: Duration } + +// Play the notes in a song. +let play tune = + for n in tune do + if n.Tone = Tone.REST then + Thread.Sleep(int n.Duration) + else + Console.Beep(int n.Tone, int n.Duration) + +// Declare the first few notes of the song, "Mary Had A Little Lamb". +let mary = + [ { Tone = Tone.B; Duration = Duration.QUARTER } + { Tone = Tone.A; Duration = Duration.QUARTER } + { Tone = Tone.GbelowC; Duration = Duration.QUARTER } + { Tone = Tone.A; Duration = Duration.QUARTER } + { Tone = Tone.B; Duration = Duration.QUARTER } + { Tone = Tone.B; Duration = Duration.QUARTER } + { Tone = Tone.B; Duration = Duration.HALF } + { Tone = Tone.A; Duration = Duration.QUARTER } + { Tone = Tone.A; Duration = Duration.QUARTER } + { Tone = Tone.A; Duration = Duration.HALF } + { Tone = Tone.B; Duration = Duration.QUARTER } + { Tone = Tone.D; Duration = Duration.QUARTER } + { Tone = Tone.D; Duration = Duration.HALF } ] + +// Play the song +play mary + +// This example plays the first few notes of "Mary Had A Little Lamb" +// through the console speaker. +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.beep2/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/console.beep2/FS/fs.fsproj new file mode 100644 index 00000000000..8a72c384666 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.beep2/FS/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.bufferHW/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/console.bufferHW/FS/fs.fsproj new file mode 100644 index 00000000000..cd5e28571b8 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.bufferHW/FS/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.bufferHW/FS/hw.fs b/samples/snippets/fsharp/VS_Snippets_CLR/console.bufferHW/FS/hw.fs new file mode 100644 index 00000000000..695845bca43 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.bufferHW/FS/hw.fs @@ -0,0 +1,13 @@ +// +// This example demonstrates the Console.BufferHeight and +// Console.BufferWidth properties. +open System + +printfn $"The current buffer height is {Console.BufferHeight} rows." +printfn $"The current buffer width is {Console.BufferWidth} columns." + +// This example produces the following results: +// +// The current buffer height is 300 rows. +// The current buffer width is 85 columns. +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.cancelkeypress/fs/ckp.fs b/samples/snippets/fsharp/VS_Snippets_CLR/console.cancelkeypress/fs/ckp.fs new file mode 100644 index 00000000000..bfa2fdda745 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.cancelkeypress/fs/ckp.fs @@ -0,0 +1,57 @@ +// +open System + +let myHandler sender (args: ConsoleCancelEventArgs) = + printfn "\nThe read operation has been interrupted." + + printfn $" Key pressed: {args.SpecialKey}" + + printfn $" Cancel property: {args.Cancel}" + + // Set the Cancel property to true to prevent the process from terminating. + printfn "Setting the Cancel property to true..." + args.Cancel <- true + + // Announce the new value of the Cancel property. + printfn $" Cancel property: {args.Cancel}" + printfn "The read operation will resume...\n" + +// Establish an event handler to process key press events. +Console.CancelKeyPress.AddHandler(ConsoleCancelEventHandler myHandler) + +let mutable quit = false +while not quit do + printf "Press any key, or 'X' to quit, or " + printfn "CTRL+C to interrupt the read operation:" + + // Start a console read operation. Do not display the input. + let cki = Console.ReadKey true + + // Announce the name of the key that was pressed . + printfn $" Key pressed: {cki.Key}\n" + + // Exit if the user pressed the 'X' key. + if cki.Key = ConsoleKey.X then + quit <- true + +// The example displays output similar to the following: +// Press any key, or 'X' to quit, or CTRL+C to interrupt the read operation: +// Key pressed: J +// +// Press any key, or 'X' to quit, or CTRL+C to interrupt the read operation: +// Key pressed: Enter +// +// Press any key, or 'X' to quit, or CTRL+C to interrupt the read operation: +// +// The read operation has been interrupted. +// Key pressed: ControlC +// Cancel property: False +// Setting the Cancel property to true... +// Cancel property: True +// The read operation will resume... +// +// Key pressed: Q +// +// Press any key, or 'X' to quit, or CTRL+C to interrupt the read operation: +// Key pressed: X +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.cancelkeypress/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/console.cancelkeypress/fs/fs.fsproj new file mode 100644 index 00000000000..ca9576147bb --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.cancelkeypress/fs/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorLTS/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorLTS/FS/fs.fsproj new file mode 100644 index 00000000000..ee197dc0280 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorLTS/FS/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorLTS/FS/lts.fs b/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorLTS/FS/lts.fs new file mode 100644 index 00000000000..62ebfc905e2 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorLTS/FS/lts.fs @@ -0,0 +1,59 @@ +// +// This example demonstrates the +// Console.CursorLeft and +// Console.CursorTop properties, and the +// Console.SetCursorPosition and +// Console.Clear methods. +open System + +// Clear the screen, then save the top and left coordinates. +Console.Clear() +let origRow = Console.CursorTop +let origCol = Console.CursorLeft + +let writeAt s x y = + try + Console.SetCursorPosition(origCol + x, origRow + y) + printfn $"%s{s}" + with :? ArgumentOutOfRangeException as e -> + Console.Clear() + printfn $"{e.Message}" + +// Draw the left side of a 5x5 rectangle, from top to bottom. +writeAt "+" 0 0 +writeAt "|" 0 1 +writeAt "|" 0 2 +writeAt "|" 0 3 +writeAt "+" 0 4 + +// Draw the bottom side, from left to right. +writeAt "-" 1 4 // shortcut: writeAt "---", 1, 4) +writeAt "-" 2 4 // ... +writeAt "-" 3 4 // ... +writeAt "+" 4 4 + +// Draw the right side, from bottom to top. +writeAt "|" 4 3 +writeAt "|" 4 2 +writeAt "|" 4 1 +writeAt "+" 4 0 + +// Draw the top side, from right to left. +writeAt "-" 3 0 // shortcut: writeAt "---", 1, 0) +writeAt "-" 2 0 // ... +writeAt "-" 1 0 // ... + +writeAt "All done!" 0 6 +printfn "" + + +// This example produces the following results: +// +// +---+ +// | | +// | | +// | | +// +---+ +// +// All done! +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorsize/FS/csize.fs b/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorsize/FS/csize.fs new file mode 100644 index 00000000000..6f4fdbae68b --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorsize/FS/csize.fs @@ -0,0 +1,33 @@ +// +// This example demonstrates the Console.CursorSize property. +open System + +let sizes = [ 1; 10; 20; 30; 40; 50; 60; 70; 80; 90; 100 ] + +let saveCursorSize = Console.CursorSize +printfn "This example increments the cursor size from 1%% to 100%%:\n" + +for size in sizes do + Console.CursorSize <- size + printfn $"Cursor size = {size}%%. (Press any key to continue...)" + + Console.ReadKey() |> ignore + +Console.CursorSize <- saveCursorSize + +// This example produces the following results: + +// This example increments the cursor size from 1% to 100%: + +// Cursor size = 1%. (Press any key to continue...) +// Cursor size = 10%. (Press any key to continue...) +// Cursor size = 20%. (Press any key to continue...) +// Cursor size = 30%. (Press any key to continue...) +// Cursor size = 40%. (Press any key to continue...) +// Cursor size = 50%. (Press any key to continue...) +// Cursor size = 60%. (Press any key to continue...) +// Cursor size = 70%. (Press any key to continue...) +// Cursor size = 80%. (Press any key to continue...) +// Cursor size = 90%. (Press any key to continue...) +// Cursor size = 100%. (Press any key to continue...) +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorsize/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorsize/FS/fs.fsproj new file mode 100644 index 00000000000..beacb7deb2b --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorsize/FS/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorvis/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorvis/FS/fs.fsproj new file mode 100644 index 00000000000..b8322c971ab --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorvis/FS/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorvis/FS/vis.fs b/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorvis/FS/vis.fs new file mode 100644 index 00000000000..c1d2ee8214e --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorvis/FS/vis.fs @@ -0,0 +1,63 @@ +// +// This example demonstrates the Console.CursorVisible property. + +open System + +Console.CursorVisible <- true // Initialize the cursor to visible. +let saveCursorVisibile = Console.CursorVisible +let saveCursorSize = Console.CursorSize +Console.CursorSize <- 100 // Emphasize the cursor. + +let mutable quit = false +while not quit do + printfn $"""\nThe cursor is {if Console.CursorVisible then "VISIBLE" else "HIDDEN"}.\nType any text then press Enter. Type '+' in the first column to show +the cursor, '-' to hide the cursor, or lowercase 'x' to quit:""" + let s = Console.ReadLine() + if not (String.IsNullOrEmpty s) then + match s[0] with + | '+' -> + Console.CursorVisible <- true + | '-' -> + Console.CursorVisible <- false + | 'x' -> + quit <- true + | _ -> () + +Console.CursorVisible <- saveCursorVisibile +Console.CursorSize <- saveCursorSize + + +// This example produces the following results. Note that these results +// cannot depict cursor visibility. You must run the example to see the +// cursor behavior: +// +// The cursor is VISIBLE. +// Type any text then press Enter. Type '+' in the first column to show +// the cursor, '-' to hide the cursor, or lowercase 'x' to quit: +// The quick brown fox +// +// The cursor is VISIBLE. +// Type any text then press Enter. Type '+' in the first column to show +// the cursor, '-' to hide the cursor, or lowercase 'x' to quit: +// - +// +// The cursor is HIDDEN. +// Type any text then press Enter. Type '+' in the first column to show +// the cursor, '-' to hide the cursor, or lowercase 'x' to quit: +// jumps over +// +// The cursor is HIDDEN. +// Type any text then press Enter. Type '+' in the first column to show +// the cursor, '-' to hide the cursor, or lowercase 'x' to quit: +// + +// +// The cursor is VISIBLE. +// Type any text then press Enter. Type '+' in the first column to show +// the cursor, '-' to hide the cursor, or lowercase 'x' to quit: +// the lazy dog. +// +// The cursor is VISIBLE. +// Type any text then press Enter. Type '+' in the first column to show +// the cursor, '-' to hide the cursor, or lowercase 'x' to quit: +// x +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.keyavailable/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/console.keyavailable/FS/fs.fsproj new file mode 100644 index 00000000000..606de2a9522 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.keyavailable/FS/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.keyavailable/FS/ka.fs b/samples/snippets/fsharp/VS_Snippets_CLR/console.keyavailable/FS/ka.fs new file mode 100644 index 00000000000..9cc5846c0d8 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.keyavailable/FS/ka.fs @@ -0,0 +1,36 @@ +// +open System +open System.Threading + +let mutable cki = Unchecked.defaultof + +while cki.Key <> ConsoleKey.X do + printfn "\nPress a key to display; press the 'x' key to quit." + + // Your code could perform some useful task in the following loop. However, + // for the sake of this example we'll merely pause for a quarter second. + + while not Console.KeyAvailable do + Thread.Sleep 250 // Loop until input is entered. + + cki <- Console.ReadKey true + printfn $"You pressed the '{cki.Key}' key." + + +// This example produces results similar to the following: +// +// Press a key to display; press the 'x' key to quit. +// You pressed the 'H' key. +// +// Press a key to display; press the 'x' key to quit. +// You pressed the 'E' key. +// +// Press a key to display; press the 'x' key to quit. +// You pressed the 'PageUp' key. +// +// Press a key to display; press the 'x' key to quit. +// You pressed the 'DownArrow' key. +// +// Press a key to display; press the 'x' key to quit. +// You pressed the 'X' key. +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.read/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/console.read/FS/fs.fsproj new file mode 100644 index 00000000000..235a40fc907 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.read/FS/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.read/FS/read.fs b/samples/snippets/fsharp/VS_Snippets_CLR/console.read/FS/read.fs new file mode 100644 index 00000000000..ee6e2e488ad --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.read/FS/read.fs @@ -0,0 +1,68 @@ +// +// This example demonstrates the Console.Read() method. +open System + +// string m2 = "Character '{0}' is hexadecimal 0x{1:x4}."; +// string m3 = "Character is hexadecimal 0x{0:x4}."; +// char ch; + +printfn "\nType a string of text then press Enter. Type '+' anywhere in the text to quit:\n" + +let mutable ch = ' ' +let mutable x = 0 + +while ch <> '+' do + x <- Console.Read() + try + ch <- Convert.ToChar x + if Char.IsWhiteSpace ch then + printfn $"Character is hexadecimal 0x{x:x4}." + if ch = char '\u000A' then + printfn "\nType a string of text then press Enter. Type '+' anywhere in the text to quit:\n" + else + printfn $"Character '{ch}' is hexadecimal 0x{x:x4}." + + with :? OverflowException as e -> + printfn $"{e.Message} Value read = {x}." + ch <- Char.MinValue + printfn "\nType a string of text then press Enter. Type '+' anywhere in the text to quit:\n" + + +// This example produces the following results: +// +// Type a string of text then press Enter. Type '+' anywhere in the text to quit: +// +// The quick brown fox. +// Character 'T' is hexadecimal 0x0054. +// Character 'h' is hexadecimal 0x0068. +// Character 'e' is hexadecimal 0x0065. +// Character is hexadecimal 0x0020. +// Character 'q' is hexadecimal 0x0071. +// Character 'u' is hexadecimal 0x0075. +// Character 'i' is hexadecimal 0x0069. +// Character 'c' is hexadecimal 0x0063. +// Character 'k' is hexadecimal 0x006b. +// Character is hexadecimal 0x0020. +// Character 'b' is hexadecimal 0x0062. +// Character 'r' is hexadecimal 0x0072. +// Character 'o' is hexadecimal 0x006f. +// Character 'w' is hexadecimal 0x0077. +// Character 'n' is hexadecimal 0x006e. +// Character is hexadecimal 0x0020. +// Character 'f' is hexadecimal 0x0066. +// Character 'o' is hexadecimal 0x006f. +// Character 'x' is hexadecimal 0x0078. +// Character '.' is hexadecimal 0x002e. +// Character is hexadecimal 0x000d. +// Character is hexadecimal 0x000a. +// +// Type a string of text then press Enter. Type '+' anywhere in the text to quit: +// +// ^Z +// Value was either too large or too small for a character. Value read = -1. +// +// Type a string of text then press Enter. Type '+' anywhere in the text to quit: +// +// + +// Character '+' is hexadecimal 0x002b. +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.readkey1/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/console.readkey1/FS/fs.fsproj new file mode 100644 index 00000000000..809a89e357a --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.readkey1/FS/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.readkey1/FS/rk.fs b/samples/snippets/fsharp/VS_Snippets_CLR/console.readkey1/FS/rk.fs new file mode 100644 index 00000000000..3a7b2e51b22 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.readkey1/FS/rk.fs @@ -0,0 +1,34 @@ +// +open System + +// Prevent example from ending if CTL+C is pressed. +Console.TreatControlCAsInput <- true + +printfn "Press any combination of CTL, ALT, and SHIFT, and a console key." +printfn "Press the Escape (Esc) key to quit: \n" + +let mutable cki = Unchecked.defaultof + +while cki.Key <> ConsoleKey.Escape do + cki <- Console.ReadKey() + printf " --- You pressed " + if int (cki.Modifiers &&& ConsoleModifiers.Alt) <> 0 then printf "ALT+" + if int (cki.Modifiers &&& ConsoleModifiers.Shift) <> 0 then printf "SHIFT+" + if int (cki.Modifiers &&& ConsoleModifiers.Control) <> 0 then printf "CTL+" + printfn $"{cki.Key}" + + +// This example displays output similar to the following: +// Press any combination of CTL, ALT, and SHIFT, and a console key. +// Press the Escape (Esc) key to quit: +// +// a --- You pressed A +// k --- You pressed ALT+K +// ► --- You pressed CTL+P +// --- You pressed RightArrow +// R --- You pressed SHIFT+R +// --- You pressed CTL+I +// j --- You pressed ALT+J +// O --- You pressed SHIFT+O +// § --- You pressed CTL+U +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.readkey2/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/console.readkey2/FS/fs.fsproj new file mode 100644 index 00000000000..a5c04f92d02 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.readkey2/FS/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.readkey2/FS/rkbool.fs b/samples/snippets/fsharp/VS_Snippets_CLR/console.readkey2/FS/rkbool.fs new file mode 100644 index 00000000000..d6d4538476d --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.readkey2/FS/rkbool.fs @@ -0,0 +1,33 @@ +// +open System + +// Prevent example from ending if CTL+C is pressed. +Console.TreatControlCAsInput <- true + +printfn "Press any combination of CTL, ALT, and SHIFT, and a console key." +printfn "Press the Escape (Esc) key to quit: \n" + +let mutable cki = Unchecked.defaultof + +while cki.Key <> ConsoleKey.Escape do + cki <- Console.ReadKey true + printf "You pressed " + if int (cki.Modifiers &&& ConsoleModifiers.Alt) <> 0 then printf "ALT+" + if int (cki.Modifiers &&& ConsoleModifiers.Shift) <> 0 then printf "SHIFT+" + if int (cki.Modifiers &&& ConsoleModifiers.Control) <> 0 then printf "CTL+" + printfn $"{cki.Key} (character '{cki.KeyChar}')" + + +// This example displays output similar to the following: +// Press any combination of CTL, ALT, and SHIFT, and a console key. +// Press the Escape (Esc) key to quit: +// +// You pressed CTL+A (character '☺') +// You pressed C (character 'c') +// You pressed CTL+C (character '♥') +// You pressed K (character 'k') +// You pressed ALT+I (character 'i') +// You pressed ALT+U (character 'u') +// You pressed ALT+SHIFT+H (character 'H') +// You pressed Escape (character '←') +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.setwindowsize/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/console.setwindowsize/FS/fs.fsproj new file mode 100644 index 00000000000..8cec0df4f46 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.setwindowsize/FS/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.setwindowsize/FS/sws.fs b/samples/snippets/fsharp/VS_Snippets_CLR/console.setwindowsize/FS/sws.fs new file mode 100644 index 00000000000..72357439e47 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.setwindowsize/FS/sws.fs @@ -0,0 +1,41 @@ +// +// This example demonstrates the Console.SetWindowSize method, +// the Console.WindowWidth property, +// and the Console.WindowHeight property. +open System + +// +// Step 1: Get the current window dimensions. +// +let origWidth = Console.WindowWidth +let origHeight = Console.WindowHeight +printfn $"The current window width is {Console.WindowWidth}, and the current window height is {Console.WindowHeight}." +printfn " (Press any key to continue...)" +Console.ReadKey true |> ignore + +// +// Step 2: Cut the window to 1/4 its original size. +// +let width = origWidth / 2 +let height = origHeight / 2 +Console.SetWindowSize(width, height) +printfn $"The new window width is {Console.WindowWidth}, and the new window height is {Console.WindowHeight}." + +printfn " (Press any key to continue...)" +Console.ReadKey true |> ignore + +// +// Step 3: Restore the window to its original size. +// +Console.SetWindowSize(origWidth, origHeight) +printfn $"The current window width is {Console.WindowWidth}, and the current window height is {Console.WindowHeight}." + + +// This example produces the following results: +// +// The current window width is 85, and the current window height is 43. +// (Press any key to continue...) +// The new window width is 42, and the new window height is 21. +// (Press any key to continue...) +// The current window width is 85, and the current window height is 43. +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.title/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/console.title/FS/fs.fsproj new file mode 100644 index 00000000000..76abce88754 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.title/FS/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.title/FS/mytitle.fs b/samples/snippets/fsharp/VS_Snippets_CLR/console.title/FS/mytitle.fs new file mode 100644 index 00000000000..48f4b85bb4e --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.title/FS/mytitle.fs @@ -0,0 +1,21 @@ +// +// This example demonstrates the Console.Title property. +open System + +printfn $"The current console title is: \"{Console.Title}\"" +printfn " (Press any key to change the console title.)" +Console.ReadKey true |> ignore + +Console.Title <- "The title has changed!" +printfn $"Note that the new console title is \"{Console.Title}\"\n (Press any key to quit.)" +Console.ReadKey true |> ignore + + +// This example produces the following results: +// +// > myTitle +// The current console title is: "Command Prompt - myTitle" +// (Press any key to change the console title.) +// Note that the new console title is "The title has changed!" +// (Press any key to quit.) +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.windowLT/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/console.windowLT/FS/fs.fsproj new file mode 100644 index 00000000000..4849b74c623 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.windowLT/FS/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.writelineFmt1/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/console.writelineFmt1/fs/fs.fsproj new file mode 100644 index 00000000000..18ef4e9515e --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.writelineFmt1/fs/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/console.writelineFmt1/fs/wl.fs b/samples/snippets/fsharp/VS_Snippets_CLR/console.writelineFmt1/fs/wl.fs new file mode 100644 index 00000000000..4cd3290402c --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/console.writelineFmt1/fs/wl.fs @@ -0,0 +1,99 @@ +// +// This code example demonstrates the Console.WriteLine() method. +// Formatting for this example uses the "en-US" culture. + +open System + +type Color = + | Yellow = 1 + | Blue = 2 + | Green = 3 + +let thisDate = DateTime.Now + +Console.Clear() + +// Format a negative integer or floating-point number in various ways. +Console.WriteLine "Standard Numeric Format Specifiers" +Console.WriteLine( + "(C) Currency: . . . . . . . . {0:C}\n" + + "(D) Decimal:. . . . . . . . . {0:D}\n" + + "(E) Scientific: . . . . . . . {1:E}\n" + + "(F) Fixed point:. . . . . . . {1:F}\n" + + "(G) General:. . . . . . . . . {0:G}\n" + + " (default):. . . . . . . . {0} (default = 'G')\n" + + "(N) Number: . . . . . . . . . {0:N}\n" + + "(P) Percent:. . . . . . . . . {1:P}\n" + + "(R) Round-trip: . . . . . . . {1:R}\n" + + "(X) Hexadecimal:. . . . . . . {0:X}\n", + -123, -123.45f) + +// Format the current date in various ways. +Console.WriteLine "Standard DateTime Format Specifiers" +Console.WriteLine( + "(d) Short date: . . . . . . . {0:d}\n" + + "(D) Long date:. . . . . . . . {0:D}\n" + + "(t) Short time: . . . . . . . {0:t}\n" + + "(T) Long time:. . . . . . . . {0:T}\n" + + "(f) Full date/short time: . . {0:f}\n" + + "(F) Full date/long time:. . . {0:F}\n" + + "(g) General date/short time:. {0:g}\n" + + "(G) General date/long time: . {0:G}\n" + + " (default):. . . . . . . . {0} (default = 'G')\n" + + "(M) Month:. . . . . . . . . . {0:M}\n" + + "(R) RFC1123:. . . . . . . . . {0:R}\n" + + "(s) Sortable: . . . . . . . . {0:s}\n" + + "(u) Universal sortable: . . . {0:u} (invariant)\n" + + "(U) Universal full date/time: {0:U}\n" + + "(Y) Year: . . . . . . . . . . {0:Y}\n", + thisDate) + +// Format a Color enumeration value in various ways. +Console.WriteLine "Standard Enumeration Format Specifiers" +Console.WriteLine( + "(G) General:. . . . . . . . . {0:G}\n" + + " (default):. . . . . . . . {0} (default = 'G')\n" + + "(F) Flags:. . . . . . . . . . {0:F} (flags or integer)\n" + + "(D) Decimal number: . . . . . {0:D}\n" + + "(X) Hexadecimal:. . . . . . . {0:X}\n", + Color.Green) + + +// This code example produces the following results: +// +// Standard Numeric Format Specifiers +// (C) Currency: . . . . . . . . ($123.00) +// (D) Decimal:. . . . . . . . . -123 +// (E) Scientific: . . . . . . . -1.234500E+002 +// (F) Fixed point:. . . . . . . -123.45 +// (G) General:. . . . . . . . . -123 +// (default):. . . . . . . . -123 (default = 'G') +// (N) Number: . . . . . . . . . -123.00 +// (P) Percent:. . . . . . . . . -12,345.00 % +// (R) Round-trip: . . . . . . . -123.45 +// (X) Hexadecimal:. . . . . . . FFFFFF85 +// +// Standard DateTime Format Specifiers +// (d) Short date: . . . . . . . 6/26/2004 +// (D) Long date:. . . . . . . . Saturday, June 26, 2004 +// (t) Short time: . . . . . . . 8:11 PM +// (T) Long time:. . . . . . . . 8:11:04 PM +// (f) Full date/short time: . . Saturday, June 26, 2004 8:11 PM +// (F) Full date/long time:. . . Saturday, June 26, 2004 8:11:04 PM +// (g) General date/short time:. 6/26/2004 8:11 PM +// (G) General date/long time: . 6/26/2004 8:11:04 PM +// (default):. . . . . . . . 6/26/2004 8:11:04 PM (default = 'G') +// (M) Month:. . . . . . . . . . June 26 +// (R) RFC1123:. . . . . . . . . Sat, 26 Jun 2004 20:11:04 GMT +// (s) Sortable: . . . . . . . . 2004-06-26T20:11:04 +// (u) Universal sortable: . . . 2004-06-26 20:11:04Z (invariant) +// (U) Universal full date/time: Sunday, June 27, 2004 3:11:04 AM +// (Y) Year: . . . . . . . . . . June, 2004 +// +// Standard Enumeration Format Specifiers +// (G) General:. . . . . . . . . Green +// (default):. . . . . . . . Green (default = 'G') +// (F) Flags:. . . . . . . . . . Green (flags or integer) +// (D) Decimal number: . . . . . 3 +// (X) Hexadecimal:. . . . . . . 00000003 +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/consolein/FS/consolein.fs b/samples/snippets/fsharp/VS_Snippets_CLR/consolein/FS/consolein.fs new file mode 100644 index 00000000000..6b170996792 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/consolein/FS/consolein.fs @@ -0,0 +1,13 @@ +// +open System + +let tIn = Console.In +let tOut = Console.Out + +tOut.WriteLine "Hola Mundo!" +tOut.Write "What is your name: " +let name = tIn.ReadLine() + +tOut.WriteLine $"Buenos Dias, {name}!" + +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/consolein/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/consolein/FS/fs.fsproj new file mode 100644 index 00000000000..2daade789a5 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/consolein/FS/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/System.Console.ReadKey/fs/ReadKey1.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/System.Console.ReadKey/fs/ReadKey1.fs new file mode 100644 index 00000000000..203f9d100ed --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/System.Console.ReadKey/fs/ReadKey1.fs @@ -0,0 +1,18 @@ +module ReadKey1 + +// +open System + +let dat = DateTime.Now +printfn $"The time: {dat:d} at {dat:t}" + +let tz = TimeZoneInfo.Local +printfn $"The time zone: {if tz.IsDaylightSavingTime dat then tz.DaylightName else tz.StandardName}\n" +printf"Press to exit... " +while Console.ReadKey().Key <> ConsoleKey.Enter do () + + +// The example displays output like the following: +// The time: 12/28/2021 at 8:35 PM +// The time zone: Pacific Standard Time +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/System.Console.ReadKey/fs/ReadKey2.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/System.Console.ReadKey/fs/ReadKey2.fs new file mode 100644 index 00000000000..def1f384ee8 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/System.Console.ReadKey/fs/ReadKey2.fs @@ -0,0 +1,18 @@ +module ReadKey2 + +// +open System + +let dat = DateTime.Now +printfn $"The time: {dat:d} at {dat:t}" + +let tz = TimeZoneInfo.Local +printfn $"The time zone: {if tz.IsDaylightSavingTime dat then tz.DaylightName else tz.StandardName}\n" +printf"Press to exit... " +while Console.ReadKey(true).Key <> ConsoleKey.Enter do () + + +// The example displays output like the following: +// The time: 12/28/2021 at 8:37 PM +// The time zone: Pacific Standard Time +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/System.Console.ReadKey/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/System.Console.ReadKey/fs/fs.fsproj new file mode 100644 index 00000000000..911e323d405 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/System.Console.ReadKey/fs/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/FS/fs.fsproj new file mode 100644 index 00000000000..329e3ff69f9 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/FS/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/FS/inserttabs.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/FS/inserttabs.fs new file mode 100644 index 00000000000..66275f1d8cf --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/FS/inserttabs.fs @@ -0,0 +1,55 @@ +// This sample opens a file whose name is passed to it as a parameter. +// It reads each line in the file and replaces every occurrence of 4 +// space characters with a tab character. +// +// It takes two command-line arguments: the input file name, and +// the output file name. +// +// Usage: +// +// INSERTTABS inputfile.txt outputfile.txt +// +// +open System +open System.IO + +let tabSize = 4 +let usageText = "Usage: INSERTTABS inputfile.txt outputfile.txt" + +[] +let main args = + if args.Length < 2 then + Console.WriteLine usageText + 1 + else + try + // Attempt to open output file. + use reader = new StreamReader(args[0]) + use writer = new StreamWriter(args[1]) + + // Redirect standard output from the console to the output file. + Console.SetOut writer + + // Redirect standard input from the console to the input file. + Console.SetIn reader + + let mutable line = Console.ReadLine() + while line <> null do + let newLine = line.Replace(("").PadRight(tabSize, ' '), "\t") + Console.WriteLine newLine + line <- Console.ReadLine() + + // Recover the standard output stream so that a + // completion message can be displayed. + let standardOutput = new StreamWriter(Console.OpenStandardOutput()) + standardOutput.AutoFlush <- true + Console.SetOut standardOutput + Console.WriteLine $"INSERTTABS has completed the processing of {args[0]}." + 0 + + with :? IOException as e -> + let errorWriter = Console.Error + errorWriter.WriteLine e.Message + errorWriter.WriteLine usageText + 1 +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/fs.fsproj new file mode 100644 index 00000000000..67185df73e9 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs new file mode 100644 index 00000000000..861ec837914 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs @@ -0,0 +1,52 @@ +open System +// This sample converts tab-delmited input and converts it to +// comma-delimited output. Furthermore, it converts all boolean +// input to numeric representations. +// System.Console.Write +// System.Console.WriteLine +// System.Console.ReadLine +// +let mutable lineInput = Console.ReadLine() +while lineInput <> null do + let fields = lineInput.Split '\t' + let mutable isFirstField = true + + for item in fields do + if isFirstField then + isFirstField <- false + else + Console.Write ',' + + // If the field represents a boolean, replace with a numeric representation. + match Boolean.TryParse item with + | true, itemBool -> + Console.Write(Convert.ToByte itemBool) + | _ -> + Console.Write item + Console.WriteLine() +// +// usage examples: +// To convert tab-delimited input from the keyboard and display +// the output (type CTRL+Z to mark the end of input): +// REFORMAT + +// To input tab-delimited data from a file and display the output: +// REFORMAT commas.txt + +// To convert tab-delimited data from a file and output the conversion +// to a file: +// REFORMAT commas.txt + +// Example input: +// 1 2.2 hello TRUE +// 2 5.22 bye FALSE +// 3 6.38 see ya' TRUE + +// Example output: +// 1,2.2,hello,1 +// 2,5.22,bye,0 +// 3,6.38,see ya',1 diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.OpenStandartInput/FS/decode.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.OpenStandartInput/FS/decode.fs new file mode 100644 index 00000000000..46aeced63fe --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.OpenStandartInput/FS/decode.fs @@ -0,0 +1,14 @@ +// System.Console.OpenStandartInput +// +open System +open System.Text + +let inputStream = Console.OpenStandardInput() +let bytes = Array.zeroCreate 100 +Console.WriteLine "To decode, type or paste the UTF7 encoded string and press enter:" +Console.WriteLine "(Example: \"M+APw-nchen ist wundervoll\")" +let outputLength = inputStream.Read(bytes, 0, 100) +let chars = Encoding.UTF7.GetChars(bytes, 0, outputLength) +Console.WriteLine "Decoded string:" +Console.WriteLine(string chars) +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.OpenStandartInput/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.OpenStandartInput/FS/fs.fsproj new file mode 100644 index 00000000000..397865f5e79 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.OpenStandartInput/FS/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/ReadLine2.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/ReadLine2.fs new file mode 100644 index 00000000000..9aaa1a9b9b1 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/ReadLine2.fs @@ -0,0 +1,27 @@ +module ReadLine2 + +// +open System + +printfn "Enter one or more lines of text (press CTRL+Z to exit):\n" + +let mutable line = "" + +while line <> null do + printf " " + line <- Console.ReadLine() + if line <> null then + printfn $" {line}" + + +// The following displays possible output from this example: +// Enter one or more lines of text (press CTRL+Z to exit): +// +// This is line #1. +// This is line #1. +// This is line #2 +// This is line #2 +// ^Z +// +// > +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/ReadLine3.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/ReadLine3.fs new file mode 100644 index 00000000000..b613e36901b --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/ReadLine3.fs @@ -0,0 +1,31 @@ +module ReadLine3 + +// +open System + +if not Console.IsInputRedirected then + printfn "This example requires that input be redirected from a file." + +printfn "About to call Console.ReadLine in a loop." +printfn "----" + +let mutable s = "" +let mutable i = 0 + +while s <> null do + i <- i + 1 + s <- Console.ReadLine() + printfn $"Line {i}: {s}" +printfn "---" + + +// The example displays the following output: +// About to call Console.ReadLine in a loop. +// ---- +// Line 1: This is the first line. +// Line 2: This is the second line. +// Line 3: This is the third line. +// Line 4: This is the fourth line. +// Line 5: +// --- +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/ReadLineSimple.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/ReadLineSimple.fs new file mode 100644 index 00000000000..e6dbb70df48 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/ReadLineSimple.fs @@ -0,0 +1,19 @@ +module ReadLineSimple + +// +open System + +Console.Clear() + +let dat = DateTime.Now + +printfn $"\nToday is {dat:d} at {dat:T}." +printf "\nPress any key to continue... " +Console.ReadLine() |> ignore + +// The example displays output like the following: +// Today is 12/28/2021 at 8:23:50 PM. +// +// Press any key to continue... + +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/fs.fsproj new file mode 100644 index 00000000000..b4170ce1dae --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/fs.fsproj @@ -0,0 +1,11 @@ + + + Exe + net6.0 + + + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.SetError/fs/SetError1.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.SetError/fs/SetError1.fs new file mode 100644 index 00000000000..7d05598cdb5 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.SetError/fs/SetError1.fs @@ -0,0 +1,32 @@ +// +open System +open System.IO +open System.Reflection + +[] +let main _ = + // Define file to receive error stream. + let appStart = DateTime.Now + let fn = @"C:\temp\errlog" + appStart.ToString "yyyyMMddHHmm" + ".log" + use fs = new FileStream(fn, FileMode.OpenOrCreate) + let errStream = new StreamWriter(fs) + let appName = + let appName = Assembly.GetExecutingAssembly().Location + appName.Substring(appName.LastIndexOf('\\') + 1) + + // Redirect standard error stream to file. + Console.SetError errStream + + // Write file header. + Console.Error.WriteLine $"Error Log for Application {appName}" + Console.Error.WriteLine() + Console.Error.WriteLine $"Application started at {appStart}." + Console.Error.WriteLine() + // + // Application code along with error output + // + // Close redirected error stream. + Console.Error.Close() + + 0 +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.SetError/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.SetError/fs/fs.fsproj new file mode 100644 index 00000000000..93b24c7af9b --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.SetError/fs/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/WriteLine6.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/WriteLine6.fs new file mode 100644 index 00000000000..57c35f20284 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/WriteLine6.fs @@ -0,0 +1,19 @@ +module WriteLine6 + +open System + +// +let rnd = Random() + +// Generate five random Boolean values. +for _ = 1 to 5 do + let bln = rnd.Next(0, 2) = 1 + Console.WriteLine $"True or False: {bln}" + +// The example displays an output similar to the following: +// True or False: False +// True or False: True +// True or False: False +// True or False: False +// True or False: True +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/WriteLine7.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/WriteLine7.fs new file mode 100644 index 00000000000..ffbb1e8cb94 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/WriteLine7.fs @@ -0,0 +1,8 @@ +// +open System + +Console.WriteLine $"Today's date: {DateTime.Now:D}" + +// The example displays output like the following: +// Today's date: Tuesday, December 28, 2021 +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/fs.fsproj new file mode 100644 index 00000000000..cbd53b7c338 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/fs.fsproj @@ -0,0 +1,14 @@ + + + Exe + net6.0 + + + + + + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/newline1.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/newline1.fs new file mode 100644 index 00000000000..2289ed8c3ee --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/newline1.fs @@ -0,0 +1,39 @@ +module newline1 + +open System + +// +let lines = + [ "This is the first line." + "This is the second line." ] + +// Output the lines using the default newline sequence. +Console.WriteLine "With the default new line characters:" +Console.WriteLine() +for line in lines do + Console.WriteLine line + +Console.WriteLine() + +// Redefine the newline characters to double space. +Console.Out.NewLine <- "\r\n\r\n" +// Output the lines using the new newline sequence. +Console.WriteLine "With redefined new line characters:" +Console.WriteLine() +for line in lines do + Console.WriteLine line + +// The example displays the following output: +// With the default new line characters: +// +// This is the first line. +// This is the second line. +// +// With redefined new line characters: +// +// +// +// This is the first line. +// +// This is the second line. +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/tipcalc.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/tipcalc.fs new file mode 100644 index 00000000000..1d9566e2f52 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/tipcalc.fs @@ -0,0 +1,30 @@ +module tipcalc + +// +open System + +let tipRate = 0.18 + +let args = Environment.GetCommandLineArgs()[1..] + +if args.Length = 0 then + Console.WriteLine "usage: TIPCALC total" +else + match Double.TryParse args[0] with + | true, billTotal -> + let tip = billTotal * tipRate + Console.WriteLine() + Console.WriteLine $"Bill total:\t{billTotal,8:c}" + Console.WriteLine $"Tip total/rate:\t{tip,8:c} ({tipRate:p1})" + Console.WriteLine("".PadRight(24, '-')) + Console.WriteLine $"Grand total:\t{billTotal + tip,8:c}" + | _ -> + Console.WriteLine "usage: TIPCALC total" + +// >tipcalc 52.23 +// +// Bill total: $52.23 +// Tip total/rate: $9.40 (18.0 %) +// ------------------------ +// Grand total: $61.63 +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/writeline_boolean1.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/writeline_boolean1.fs new file mode 100644 index 00000000000..798bfa093d2 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/writeline_boolean1.fs @@ -0,0 +1,19 @@ +module writeline_boolean1 + +open System + +// +// Assign 10 random integers to an array. +let rnd = Random() +let numbers = + [ for _ = 0 to 9 do + rnd.Next()] + +// Determine whether the numbers are even or odd. +for number in numbers do + let even = number % 2 = 0 + Console.WriteLine $"Is {number} even:" + Console.WriteLine even + Console.WriteLine() + +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/writeline_obj1.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/writeline_obj1.fs new file mode 100644 index 00000000000..c9a73b00ade --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/writeline_obj1.fs @@ -0,0 +1,19 @@ +module writeline_obj1 + +open System + +// +let values: obj [] = + [| true; 12.632; 17908; "stringValue"; 'a'; 16907.32M |] + +for value in values do + Console.WriteLine value + +// The example displays the following output: +// True +// 12.632 +// 17908 +// stringValue +// a +// 16907.32 +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.backgroundcolor/fs/backgroundcolor1.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.backgroundcolor/fs/backgroundcolor1.fs new file mode 100644 index 00000000000..d65832b5e4e --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.backgroundcolor/fs/backgroundcolor1.fs @@ -0,0 +1,21 @@ +// +open System + +let writeCharacterStrings start end' changeColor = + for i = start to end' do + if changeColor then + Console.BackgroundColor <- (i - 1) % 16 |> enum + + Console.WriteLine(String(char (i + 64), 30)) + +writeCharacterStrings 1 26 true +Console.MoveBufferArea(0, Console.CursorTop - 10, 30, 1, Console.CursorLeft, Console.CursorTop + 1) +Console.CursorTop <- Console.CursorTop + 3 +Console.WriteLine "Press any key..." +Console.ReadKey() |> ignore + +Console.Clear() +writeCharacterStrings 1 26 false + + +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.backgroundcolor/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.backgroundcolor/fs/fs.fsproj new file mode 100644 index 00000000000..48648f0eb11 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.backgroundcolor/fs/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class.unsafe/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class.unsafe/fs/fs.fsproj new file mode 100644 index 00000000000..1d96cd521a2 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class.unsafe/fs/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/fs.fsproj new file mode 100644 index 00000000000..334f8031df9 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/fs.fsproj @@ -0,0 +1,12 @@ + + + Exe + net6.0 + + + + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.clear/fs/clear1.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.clear/fs/clear1.fs new file mode 100644 index 00000000000..928886a70ce --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.clear/fs/clear1.fs @@ -0,0 +1,67 @@ +// +open System + +let getKeyPress msg validChars = + Console.WriteLine() + + let mutable valid = false + let mutable keyChar = ' ' + + while not valid do + printfn "%s" msg + let keyPressed = Console.ReadKey() + printfn "" + if validChars |> List.exists (fun ch -> ch.Equals(Char.ToUpper keyPressed.KeyChar)) then + valid <- true + keyChar <- keyPressed.KeyChar + keyChar + +// Save colors so they can be restored when use finishes input. +let dftForeColor = Console.ForegroundColor +let dftBackColor = Console.BackgroundColor +let mutable continueFlag = true +Console.Clear() + +while continueFlag do + let foreColorSelection = + getKeyPress "Select Text Color (B for Blue, R for Red, Y for Yellow): " [ 'B'; 'R'; 'Y' ] + + let newForeColor = + match foreColorSelection with + | 'B' | 'b' -> + ConsoleColor.DarkBlue + | 'R' | 'r' -> + ConsoleColor.DarkRed + | 'Y' | 'y' -> + ConsoleColor.DarkYellow + | _ -> ConsoleColor.White + + let backColorSelection = + getKeyPress "Select Background Color (W for White, G for Green, M for Magenta): " [ 'W'; 'G'; 'M' ] + + let newBackColor = + match backColorSelection with + | 'W' | 'w' -> + ConsoleColor.White + | 'G' | 'g' -> + ConsoleColor.Green + | 'M' | 'm' -> + ConsoleColor.Magenta + | _ -> ConsoleColor.Black + + printfn "" + printf "Enter a message to display: " + let textToDisplay = Console.ReadLine() + printfn "" + Console.ForegroundColor <- newForeColor + Console.BackgroundColor <- newBackColor + printfn "%s" textToDisplay + printfn "" + if Char.ToUpper(getKeyPress "Display another message (Y/N): " [ 'Y'; 'N' ] ) = 'N' then + continueFlag <- false + + // Restore the default settings and clear the screen. + Console.ForegroundColor <- dftForeColor + Console.BackgroundColor <- dftBackColor + Console.Clear() +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.clear/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.clear/fs/fs.fsproj new file mode 100644 index 00000000000..3d71b169ecd --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.clear/fs/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.error/fs/error1.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.error/fs/error1.fs new file mode 100644 index 00000000000..478e7a63ce7 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.error/fs/error1.fs @@ -0,0 +1,31 @@ +// +open System + +let mutable increment = 0 +let mutable exitFlag = false + +while not exitFlag do + if Console.IsOutputRedirected then + Console.Error.WriteLine $"Generating multiples of numbers from {increment + 1} to {increment + 10}" + + Console.WriteLine $"Generating multiples of numbers from {increment + 1} to {increment + 10}" + + for i = increment + 1 to increment + 10 do + Console.Write $"Multiples of {i}: " + for j = 1 to 10 do + Console.Write $"""{i * j}{if j = 10 then "" else ", "}""" + + Console.WriteLine() + Console.WriteLine() + + increment <- increment + 10 + Console.Error.Write $"Display multiples of {increment + 1} through {increment + 10} (y/n)? " + let response = Console.ReadKey(true).KeyChar + Console.Error.WriteLine response + if not Console.IsOutputRedirected then + Console.CursorTop <- Console.CursorTop - 1 + + if Char.ToUpperInvariant response = 'N' then + exitFlag <- true + +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.error/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.error/fs/fs.fsproj new file mode 100644 index 00000000000..abe3ff2ab6f --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.error/fs/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.openstandarderror/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.openstandarderror/fs/fs.fsproj new file mode 100644 index 00000000000..1b502e55acf --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.openstandarderror/fs/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.openstandarderror/fs/viewtextfile.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.openstandarderror/fs/viewtextfile.fs new file mode 100644 index 00000000000..f0edfd39ce4 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.openstandarderror/fs/viewtextfile.fs @@ -0,0 +1,43 @@ +// +open System +open System.IO + +let args = Environment.GetCommandLineArgs()[1..] +let mutable errorOutput = "" +// Make sure that there is at least one command line argument. +if args.Length < 1 then + errorOutput <- errorOutput + "You must include a filename on the command line.\n" + +for file in args do + // Check whether the file exists. + if File.Exists file then + errorOutput <- errorOutput + $"'{file}' does not exist.\n" + else + // Display the contents of the file. + use sr = new StreamReader(file) + let contents = sr.ReadToEnd() + Console.WriteLine $"*****Contents of file '{file}':\n\n" + Console.WriteLine contents + Console.WriteLine "*****\n" + +// Check for error conditions. +if not (String.IsNullOrEmpty errorOutput) then + // Write error information to a file. + Console.SetError(new StreamWriter(@".\ViewTextFile.Err.txt")) + Console.Error.WriteLine errorOutput + Console.Error.Close() + // Reacquire the standard error stream. + use standardError = new StreamWriter(Console.OpenStandardError()) + standardError.AutoFlush <- true + Console.SetError standardError + Console.Error.WriteLine "\nError information written to ViewTextFile.Err.txt" + +// If the example is compiled and run with the following command line: +// ViewTextFile file1.txt file2.txt +// and neither file1.txt nor file2.txt exist, it displays the +// following output: +// Error information written to ViewTextFile.Err.txt +// and writes the following text to ViewTextFile.Err.txt: +// 'file1.txt' does not exist. +// 'file2.txt' does not exist. +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.out/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.out/fs/fs.fsproj new file mode 100644 index 00000000000..add700b9068 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.out/fs/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.out/fs/out1.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.out/fs/out1.fs new file mode 100644 index 00000000000..fd48d9d421f --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.out/fs/out1.fs @@ -0,0 +1,32 @@ +// +open System +open System.IO + +// Get all files in the current directory. +let files = + Directory.GetFiles "." + |> Array.sort + +// Display the files to the current output source to the console. +Console.Out.WriteLine "First display of filenames to the console:" +files |> Array.iter Console.Out.WriteLine +Console.Out.WriteLine() + +// Redirect output to a file named Files.txt and write file list. +let sw = new StreamWriter(@".\Files.txt") +sw.AutoFlush <- true +Console.SetOut sw +Console.Out.WriteLine "Display filenames to a file:" +files |> Array.iter Console.Out.WriteLine +Console.Out.WriteLine() + +// Close previous output stream and redirect output to standard output. +Console.Out.Close() +let sw2 = new StreamWriter(Console.OpenStandardOutput()) +sw2.AutoFlush <- true +Console.SetOut sw2 + +// Display the files to the current output source to the console. +Console.Out.WriteLine "Second display of filenames to the console:" +files |> Array.iter Console.Out.WriteLine +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.setout/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.setout/fs/fs.fsproj new file mode 100644 index 00000000000..fbff4133403 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.setout/fs/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.setout/fs/source.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.setout/fs/source.fs new file mode 100644 index 00000000000..266d565e390 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.setout/fs/source.fs @@ -0,0 +1,17 @@ +open System +open System.IO + +[] +let main _ = + // + Console.WriteLine "Hello World" + use fs = new FileStream("Test.txt", FileMode.Create) + // First, save the standard output. + let tmp = Console.Out + use sw = new StreamWriter(fs) + Console.SetOut sw + Console.WriteLine "Hello file" + Console.SetOut tmp + Console.WriteLine "Hello World" + // + 0 \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.windowleft/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.windowleft/fs/fs.fsproj new file mode 100644 index 00000000000..1e8b6d61dda --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.windowleft/fs/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.windowleft/fs/windowleft1.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.windowleft/fs/windowleft1.fs new file mode 100644 index 00000000000..f1a35399659 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.windowleft/fs/windowleft1.fs @@ -0,0 +1,36 @@ +// +open System + +let showConsoleStatistics () = + printfn "Console statistics:" + printfn $" Buffer: {Console.BufferHeight} x {Console.BufferWidth}" + printfn $" Window: {Console.WindowHeight} x {Console.WindowWidth}" + printfn $" Window starts at {Console.WindowLeft}." + printfn "Press <- or -> to move window, Ctrl+C to exit." + +Console.BufferWidth <- Console.BufferWidth + 4 +Console.Clear() + +showConsoleStatistics () + +let mutable moved = false + +while true do + let key = Console.ReadKey true + if key.Key = ConsoleKey.LeftArrow then + let pos = Console.WindowLeft - 1 + if pos >= 0 && pos + Console.WindowWidth <= Console.BufferWidth then + Console.WindowLeft <- pos + moved <- true + elif key.Key = ConsoleKey.RightArrow then + let pos = Console.WindowLeft + 1 + if pos + Console.WindowWidth <= Console.BufferWidth then + Console.WindowLeft <- pos + moved <- true + if moved then + showConsoleStatistics () + moved <- false + + printfn "" + +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.write/fs/WriteParams1.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.write/fs/WriteParams1.fs new file mode 100644 index 00000000000..27e6b4401b7 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.write/fs/WriteParams1.fs @@ -0,0 +1,35 @@ +module WriteParams1 + +// +open System + +type Person = + { Name: string + BirthDate: DateOnly + Height: double + Weight: double + Gender: char + Remarks: string } + + member this.GetDescription(): obj [] = + [| this.Name; this.Gender; this.Height; this.Weight; this.BirthDate |] + +let p1 = + { Name = "John" + Gender = 'M' + BirthDate = DateOnly(1992, 5, 10) + Height = 73.5 + Weight = 207 + Remarks = "Client since 1/3/2012" } + +Console.Write("{0}: {1}, born {4:d} Height {2} inches, Weight {3} lbs ", p1.GetDescription()) + +if String.IsNullOrEmpty p1.Remarks then + Console.WriteLine() +else + Console.WriteLine $"""{if Console.CursorLeft + p1.Remarks.Length + 10 > Console.WindowWidth then "\n " else ""}Remarks: {p1.Remarks}""" + + +// The example displays the following output: +// John: M, born 5/10/1992 Height 73.5 inches, Weight 207 lbs Remarks: Client since 1/3/2012 +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.write/fs/WriteParams2.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.write/fs/WriteParams2.fs new file mode 100644 index 00000000000..3d105d8931b --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.write/fs/WriteParams2.fs @@ -0,0 +1,34 @@ +module WriteParams2 + +// +open System + +type Person = + { Name: string + BirthDate: DateOnly + Height: double + Weight: double + Gender: char + Remarks: string } + + member this.GetDescription(): obj [] = + [| this.Name; this.Gender; this.Height; this.Weight; this.BirthDate |] + +let p1 = + { Name = "John" + Gender = 'M' + BirthDate = DateOnly(1992, 5, 10) + Height = 73.5 + Weight = 207 + Remarks = "Client since 1/3/2012" } + +printf $"{p1.Name}: {p1.Gender}, born {p1.BirthDate:d} Height {p1.Height} inches, Weight {p1.Weight} lbs " +if String.IsNullOrEmpty p1.Remarks then + Console.WriteLine() +else + Console.WriteLine $"""{if Console.CursorLeft + p1.Remarks.Length + 10 > Console.WindowWidth then "\n " else ""}Remarks: {p1.Remarks}""" + + +// The example displays the following output: +// John: M, born 5/10/1992 Height 73.5 inches, Weight 207 lbs Remarks: Client since 1/3/2012 +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.write/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.write/fs/fs.fsproj new file mode 100644 index 00000000000..407f90b87e0 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.write/fs/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolecolor/fs/Example2.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolecolor/fs/Example2.fs new file mode 100644 index 00000000000..ecdadcccc0a --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolecolor/fs/Example2.fs @@ -0,0 +1,11 @@ +module Example2 + +// +open System + +if Console.BackgroundColor = ConsoleColor.Black then + Console.BackgroundColor <- ConsoleColor.Red + Console.ForegroundColor <- ConsoleColor.Black + Console.Clear() + +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolecolor/fs/foregroundcolor3.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolecolor/fs/foregroundcolor3.fs new file mode 100644 index 00000000000..c9ea4e839c0 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolecolor/fs/foregroundcolor3.fs @@ -0,0 +1,74 @@ +module foregroundcolor3 + +// +open System + +// Get an array with the values of ConsoleColor enumeration members. +let colors = ConsoleColor.GetValues() + +// Save the current background and foreground colors. +let currentBackground = Console.BackgroundColor +let currentForeground = Console.ForegroundColor + +// Display all foreground colors except the one that matches the background. +printfn $"All the foreground colors except {currentBackground}, the background color:" + +for color in colors do + if color <> currentBackground then + Console.ForegroundColor <- color + printfn $" The foreground color is {color}." +printfn "" + +// Restore the foreground color. +Console.ForegroundColor <- currentForeground; + +// Display each background color except the one that matches the current foreground color. +printfn $"All the background colors except {currentForeground}, the foreground color:" + +for color in colors do + if color <> currentForeground then + Console.BackgroundColor <- color + printfn $" The background color is {color}." + +// Restore the original console colors. +Console.ResetColor() +printfn "\nOriginal colors restored..." + + +//The example displays output like the following: +// All the foreground colors except DarkCyan, the background color: +// The foreground color is Black. +// The foreground color is DarkBlue. +// The foreground color is DarkGreen. +// The foreground color is DarkRed. +// The foreground color is DarkMagenta. +// The foreground color is DarkYellow. +// The foreground color is Gray. +// The foreground color is DarkGray. +// The foreground color is Blue. +// The foreground color is Green. +// The foreground color is Cyan. +// The foreground color is Red. +// The foreground color is Magenta. +// The foreground color is Yellow. +// The foreground color is White. +// +// All the background colors except White, the foreground color: +// The background color is Black. +// The background color is DarkBlue. +// The background color is DarkGreen. +// The background color is DarkCyan. +// The background color is DarkRed. +// The background color is DarkMagenta. +// The background color is DarkYellow. +// The background color is Gray. +// The background color is DarkGray. +// The background color is Blue. +// The background color is Green. +// The background color is Cyan. +// The background color is Red. +// The background color is Magenta. +// The background color is Yellow. +// +// Original colors restored... +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolecolor/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolecolor/fs/fs.fsproj new file mode 100644 index 00000000000..951d72fa28d --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolecolor/fs/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/xml/System/Console.xml b/xml/System/Console.xml index c75240a386b..54aacc11105 100644 --- a/xml/System/Console.xml +++ b/xml/System/Console.xml @@ -266,6 +266,7 @@ A change to the property affects only output that is written to individual character cells after the background color is changed. To change the background color of the console window as a whole, set the property and call the method. The following example provides an illustration. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.console.backgroundcolor/cs/backgroundcolor1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.backgroundcolor/fs/backgroundcolor1.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.console.backgroundcolor/vb/backgroundcolor1.vb" id="Snippet1"::: A get operation for a Windows-based application, in which a console does not exist, returns . @@ -276,6 +277,7 @@ The following example saves the values of the enumeration to an array and stores the current values of the and properties to variables. It then changes the foreground color to each color in the enumeration except to the color that matches the current background, and it changes the background color to each color in the enumeration except to the color that matches the current foreground. (If the foreground color is the same as the background color, the text isn't visible.) Finally, it calls the method to restore the original console colors. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.consolecolor/cs/foregroundcolor3.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolecolor/fs/foregroundcolor3.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.consolecolor/vb/foregroundcolor3.vb" id="Snippet1"::: ]]> @@ -365,6 +367,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.beep/CPP/beep.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.beep/CS/beep.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.beep/FS/beep.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.beep/VB/beep.vb" id="Snippet1"::: ]]> @@ -437,6 +440,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.beep2/CPP/b2.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.beep2/CS/b2.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.beep2/FS/b2.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.beep2/VB/b2.vb" id="Snippet1"::: ]]> @@ -530,6 +534,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.bufferHW/CPP/hw.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.bufferHW/CS/hw.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.bufferHW/FS/hw.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.bufferHW/VB/hw.vb" id="Snippet1"::: ]]> @@ -625,6 +630,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.bufferHW/CPP/hw.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.bufferHW/CS/hw.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.bufferHW/FS/hw.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.bufferHW/VB/hw.vb" id="Snippet1"::: ]]> @@ -727,6 +733,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.cancelkeypress/cpp/ckp.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.cancelkeypress/cs/ckp.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.cancelkeypress/fs/ckp.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.cancelkeypress/vb/ckp.vb" id="Snippet1"::: ]]> @@ -852,6 +859,7 @@ The following example uses the method to clear the console before it executes a loop, prompts the user to select a foreground and background color and to enter a string to display. If the user chooses not to exit the program, the console's original foreground and background colors are restored and the method is called again before re-executing the loop. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.console.clear/cs/clear1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.clear/fs/clear1.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.console.clear/vb/clear1.vb" id="Snippet1"::: The example relies on a `GetKeyPress` method to validate the user's selection of a foreground and background color. @@ -860,6 +868,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.cursorLTS/CPP/lts.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.cursorLTS/CS/lts.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorLTS/FS/lts.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.cursorLTS/VB/lts.vb" id="Snippet1"::: ]]> @@ -935,6 +944,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.cursorLTS/CPP/lts.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.cursorLTS/CS/lts.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorLTS/FS/lts.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.cursorLTS/VB/lts.vb" id="Snippet1"::: ]]> @@ -1025,6 +1035,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.cursorsize/CPP/csize.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.cursorsize/CS/csize.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorsize/FS/csize.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.cursorsize/VB/csize.vb" id="Snippet1"::: ]]> @@ -1103,6 +1114,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.cursorLTS/CPP/lts.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.cursorLTS/CS/lts.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorLTS/FS/lts.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.cursorLTS/VB/lts.vb" id="Snippet1"::: ]]> @@ -1189,6 +1201,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.cursorvis/CPP/vis.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.cursorvis/CS/vis.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorvis/FS/vis.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.cursorvis/VB/vis.vb" id="Snippet1"::: ]]> @@ -1248,6 +1261,7 @@ In console applications whose informational output is often redirected to a file, the standard error stream available through the property can be used to display information to the console even if output is redirected. The following example displays product tables for 10 numbers at a time starting with 1. After every set of 10 numbers, the property is used to ask the user whether to display the next set. If the standard output is redirected to a file, the user is still asked whether the routine should generate the next set of products. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.console.error/cs/error1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.error/fs/error1.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.console.error/vb/error1.vb" id="Snippet1"::: @@ -1257,11 +1271,13 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/Console-EXPANDTABSEX/CPP/expandtabsex.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/Console-EXPANDTABSEX/CS/expandtabsex.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/Console-EXPANDTABSEX/FS/expandtabsex.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/Console-EXPANDTABSEX/VB/expandtabsex.vb" id="Snippet1"::: The following example is a simple text file viewer that displays the contents of one or more text files to the console. If there are no command line arguments, or if any files passed as command line arguments do not exist, the example calls the method to redirect error information to a file, calls the method in the process of reacquiring the standard error stream, and indicates that error information was written to a file. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.console.openstandarderror/cs/viewtextfile.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.openstandarderror/fs/viewtextfile.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.console.openstandarderror/vb/viewtextfile.vb" id="Snippet1"::: Note that the property is set to `true` before reacquiring the error stream. This ensures that output will be sent to the console immediately rather than buffered. @@ -1347,11 +1363,13 @@ The following example checks whether the console's background color is black and, if it is, it changes the background color to red and the foreground color to black. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.consolecolor/cs/Example2.cs" id="Snippet2"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolecolor/fs/Example2.fs" id="Snippet2"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.consolecolor/vb/Example2.vb" id="Snippet2"::: The following example saves the values of the enumeration to an array and stores the current values of the and properties to variables. It then changes the foreground color to each color in the enumeration except to the color that matches the current background, and it changes the background color to each color in the enumeration except to the color that matches the current foreground. (If the foreground color is the same as the background color, the text isn't visible.) Finally, it calls the method to restore the original console colors. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.consolecolor/cs/foregroundcolor3.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolecolor/fs/foregroundcolor3.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.consolecolor/vb/foregroundcolor3.vb" id="Snippet1"::: ]]> @@ -1491,6 +1509,7 @@ Columns are numbered from left to right starting at 0. Rows are numbered from to :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/consolein/CPP/consolein.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/consolein/CS/consolein.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/consolein/FS/consolein.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/consolein/VB/consolein.vb" id="Snippet1"::: ]]> @@ -1772,6 +1791,7 @@ Columns are numbered from left to right starting at 0. Rows are numbered from to :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.keyavailable/CPP/ka.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.keyavailable/CS/ka.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.keyavailable/FS/ka.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.keyavailable/VB/ka.vb" id="Snippet1"::: ]]> @@ -2210,6 +2230,7 @@ Columns are numbered from left to right starting at 0. Rows are numbered from to The following example is a simple text file viewer that displays the contents of one or more text files to the console. If there are no command line arguments, or if any files passed as command line arguments do not exist, the example calls the method to redirect error information to a file, calls the method in the process of reacquiring the standard error stream, and indicates that error information was written to a file. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.console.openstandarderror/cs/viewtextfile.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.openstandarderror/fs/viewtextfile.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.console.openstandarderror/vb/viewtextfile.vb" id="Snippet1"::: Note that the property is set to `true` before reacquiring the error stream. This ensures that output will be sent to the console immediately rather than buffered. @@ -2351,6 +2372,7 @@ The following example illustrates the use of the `OpenStandardInput` method. :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console.OpenStandartInput/CPP/decode.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.OpenStandartInput/CS/decode.cs" id="Snippet1"::: +:::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.OpenStandartInput/FS/decode.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.OpenStandartInput/VB/decode.vb" id="Snippet1"::: ]]> @@ -2483,6 +2505,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console-INSERTTABS/CPP/inserttabs.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/CS/inserttabs.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/FS/inserttabs.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-INSERTTABS/VB/inserttabs.vb" id="Snippet1"::: ]]> @@ -2543,6 +2566,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console-INSERTTABS/CPP/inserttabs.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/CS/inserttabs.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/FS/inserttabs.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-INSERTTABS/VB/inserttabs.vb" id="Snippet1"::: ]]> @@ -2609,6 +2633,7 @@ This method can be used to reacquire the standard output stream after it has bee The following example uses the property to display an array containing the names of files in the application's current directory to the standard output device. It then sets the standard output to a file named Files.txt and lists the array elements to the file. Finally, it sets the output to the standard output stream and again displays the array elements to the standard output device. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.console.out/cs/out1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.out/fs/out1.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.console.out/vb/out1.vb" id="Snippet1"::: ]]> @@ -2768,6 +2793,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.read/CPP/read.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.read/CS/read.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.read/FS/read.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.read/VB/read.vb" id="Snippet1"::: ]]> @@ -2855,6 +2881,7 @@ This method can be used to reacquire the standard output stream after it has bee One of the most common uses of the method is to halt program execution until the user presses a key and the app either terminates or displays an additional window of information. The following example uses the method to wait for the user to press the Enter key before terminating the app. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/System.Console.ReadKey/cs/ReadKey1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/System.Console.ReadKey/fs/ReadKey1.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.Console.ReadKey/vb/ReadKey1.vb" id="Snippet1"::: Note that this overload of the method by default echoes any displayable keys that the user presses to the console. To suppress them, call the method with an `intercept` argument of `true`. @@ -2863,6 +2890,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.readkey1/CPP/rk.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.readkey1/CS/rk.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.readkey1/FS/rk.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.readkey1/VB/rk.vb" id="Snippet1"::: ]]> @@ -2950,12 +2978,14 @@ This method can be used to reacquire the standard output stream after it has bee One of the most common uses of the method is to halt program execution until the user presses a key and the app either terminates or displays an additional window of information. The following example uses the method to wait for the user to press the Enter key before terminating the app. Note that, if the user presses any other key, it is not echoed to the console. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/System.Console.ReadKey/cs/ReadKey2.cs" id="Snippet2"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/System.Console.ReadKey/fs/ReadKey2.fs" id="Snippet2"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.Console.ReadKey/vb/ReadKey2.vb" id="Snippet2"::: The following example uses the method to display information about the key pressed by a user without echoing that key to the console. :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.readkey2/CPP/rkbool.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.readkey2/CS/rkbool.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.readkey2/FS/rkbool.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.readkey2/VB/rkbool.vb" id="Snippet1"::: ]]> @@ -3026,6 +3056,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console.ReadLine/cpp/ReadLineSimple.cpp" id="Snippet6"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.ReadLine/cs/ReadLineSimple.cs" id="Snippet6"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/ReadLineSimple.fs" id="Snippet6"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.ReadLine/vb/ReadLineSimple.vb" id="Snippet6"::: - If standard input is redirected to a file, the method reads a line of text from a file. For example, the following is a text file named ReadLine1.txt: @@ -3042,6 +3073,7 @@ This method can be used to reacquire the standard output stream after it has bee The following example uses the method to read input that is redirected from a file. The read operation terminates when the method returns `null`, which indicates that no lines remain to be read. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.ReadLine/cs/ReadLine3.cs" id="Snippet3"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/ReadLine3.fs" id="Snippet3"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.ReadLine/vb/ReadLine3.vb" id="Snippet3"::: After compiling the example to an executable named ReadLine1.exe, you can run it from the command line to read the contents of the file and display them to the console. The syntax is: @@ -3060,6 +3092,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console.ReadLine/cpp/readline2.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.ReadLine/cs/ReadLine2.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/ReadLine2.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.ReadLine/vb/ReadLine2.vb" id="Snippet1"::: ## Examples @@ -3067,6 +3100,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console-INSERTTABS/CPP/inserttabs.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/CS/inserttabs.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/FS/inserttabs.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-INSERTTABS/VB/inserttabs.vb" id="Snippet1"::: ]]> @@ -3147,6 +3181,7 @@ This method can be used to reacquire the standard output stream after it has bee The following example saves the values of the enumeration to an array and stores the current values of the and properties to variables. It then changes the foreground color to each color in the enumeration except to the color that matches the current background, and it changes the background color to each color in the enumeration except to the color that matches the current foreground. (If the foreground color is the same as the background color, the text isn't visible.) Finally, it calls the method to restore the original console colors. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.consolecolor/cs/foregroundcolor3.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolecolor/fs/foregroundcolor3.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.consolecolor/vb/foregroundcolor3.vb" id="Snippet1"::: ]]> @@ -3312,6 +3347,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.cursorLTS/CPP/lts.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.cursorLTS/CS/lts.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.cursorLTS/FS/lts.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.cursorLTS/VB/lts.vb" id="Snippet1"::: ]]> @@ -3389,6 +3425,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console.SetError/cpp/seterror1.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.SetError/cs/SetError1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.SetError/fs/SetError1.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.SetError/vb/SetError1.vb" id="Snippet1"::: ]]> @@ -3475,6 +3512,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console-INSERTTABS/CPP/inserttabs.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/CS/inserttabs.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/FS/inserttabs.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-INSERTTABS/VB/inserttabs.vb" id="Snippet1"::: ]]> @@ -3540,6 +3578,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.console.setout/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.console.setout/cs/source.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.setout/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.console.setout/vb/source.vb" id="Snippet1"::: The actual object returned by may be a synchronized wrapper around the provided text writer. @@ -3549,6 +3588,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console-INSERTTABS/CPP/inserttabs.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/CS/inserttabs.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/FS/inserttabs.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-INSERTTABS/VB/inserttabs.vb" id="Snippet1"::: ]]> @@ -3703,6 +3743,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.setwindowsize/CPP/sws.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.setwindowsize/CS/sws.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.setwindowsize/FS/sws.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.setwindowsize/VB/sws.vb" id="Snippet1"::: ]]> @@ -3794,6 +3835,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.title/CPP/mytitle.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.title/CS/mytitle.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.title/FS/mytitle.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.title/VB/mytitle.vb" id="Snippet1"::: ]]> @@ -3882,6 +3924,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.readkey1/CPP/rk.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.readkey1/CS/rk.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.readkey1/FS/rk.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.readkey1/VB/rk.vb" id="Snippet1"::: ]]> @@ -3971,6 +4014,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.setwindowsize/CPP/sws.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.setwindowsize/CS/sws.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.setwindowsize/FS/sws.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.setwindowsize/VB/sws.vb" id="Snippet1"::: ]]> @@ -4055,6 +4099,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.console.windowleft/cpp/windowleft1.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.console.windowleft/cs/windowleft1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.windowleft/fs/windowleft1.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.console.windowleft/vb/windowleft1.vb" id="Snippet1"::: ]]> @@ -4224,6 +4269,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.setwindowsize/CPP/sws.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.setwindowsize/CS/sws.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.setwindowsize/FS/sws.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.setwindowsize/VB/sws.vb" id="Snippet1"::: ]]> @@ -4302,6 +4348,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console-REFORMAT/CS/reformat.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: ]]> @@ -4358,6 +4405,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console-REFORMAT/CS/reformat.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: ]]> @@ -4465,6 +4513,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console-REFORMAT/CS/reformat.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: ]]> @@ -4526,6 +4575,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console-REFORMAT/CS/reformat.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: ]]> @@ -4587,6 +4637,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console-REFORMAT/CS/reformat.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: ]]> @@ -4648,6 +4699,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console-REFORMAT/CS/reformat.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: ]]> @@ -4710,6 +4762,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console-REFORMAT/CS/reformat.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: ]]> @@ -4771,6 +4824,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console-REFORMAT/CS/reformat.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: ]]> @@ -4833,6 +4887,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console-REFORMAT/CS/reformat.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: ]]> @@ -4900,6 +4955,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console-REFORMAT/CS/reformat.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: ]]> @@ -4967,6 +5023,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console-REFORMAT/CS/reformat.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: ]]> @@ -5047,12 +5104,14 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.writelineFmt1/cpp/wl.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.writelineFmt1/cs/wl.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.writelineFmt1/fs/wl.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.writelineFmt1/vb/wl.vb" id="Snippet1"::: The following example illustrates the use of the method. :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console-REFORMAT/CS/reformat.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: ]]> @@ -5146,6 +5205,7 @@ This method can be used to reacquire the standard output stream after it has bee The following example defines a `Person` class with a number of properties that provide information about a person. Its `GetDescription` method returns an array that contains all of the property values except one. The example then uses the array returned by the `GetDescription` method to display the values of the Person object. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.console.write/cs/WriteParams1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.write/fs/WriteParams1.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.console.write/vb/WriteParams1.vb" id="Snippet1"::: Note that the example calls the method rather than the method because it attempts to display the value of the `Person.Remarks` property on the same line. To do this, it examines the value of the and properties to determine whether there is enough space for the remark to fit. If there is, it displays the line. If not, it writes a line, indents three spaces, and displays the remark. @@ -5153,6 +5213,7 @@ This method can be used to reacquire the standard output stream after it has bee The following example is identical to the first, except that it supplies a five-item list as the `arg` argument instead of a parameter array. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.console.write/cs/WriteParams2.cs" id="Snippet2"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.write/fs/WriteParams2.fs" id="Snippet2"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.console.write/vb/WriteParams2.vb" id="Snippet2"::: ]]> @@ -5305,12 +5366,14 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.writelineFmt1/cpp/wl.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.writelineFmt1/cs/wl.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.writelineFmt1/fs/wl.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.writelineFmt1/vb/wl.vb" id="Snippet1"::: The following example illustrates the use of the `Write` method. :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console-REFORMAT/CS/reformat.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: ]]> @@ -5400,12 +5463,14 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.writelineFmt1/cpp/wl.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.writelineFmt1/cs/wl.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.writelineFmt1/fs/wl.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.writelineFmt1/vb/wl.vb" id="Snippet1"::: The following example illustrates the use of the `Write` method. :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console-REFORMAT/CS/reformat.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: ]]> @@ -5584,6 +5649,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console.WriteLine/CPP/newline1.cpp" id="Snippet2"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.WriteLine/CS/newline1.cs" interactive="try-dotnet-method" id="Snippet2"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/newline1.fs" id="Snippet2"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/newline1.vb" id="Snippet2"::: ]]> @@ -5649,6 +5715,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console.WriteLine/CPP/writeline_boolean1.cpp" id="Snippet4"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.WriteLine/CS/writeline_boolean1.cs" interactive="try-dotnet-method" id="Snippet4"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/writeline_boolean1.fs" id="Snippet4"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/writeline_boolean1.vb" id="Snippet4"::: ]]> @@ -5709,6 +5776,7 @@ This method can be used to reacquire the standard output stream after it has bee The following example is a tip calculator that calculates an 18% tip and uses the method to display the amount of the original charge, the amount of the tip, and the total amount. The example is a console application that requires the user to supply the amount of the original charge as a command-line parameter. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.WriteLine/CS/tipcalc.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/tipcalc.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/tipcalc.vb" id="Snippet1"::: ]]> @@ -5824,6 +5892,7 @@ This method can be used to reacquire the standard output stream after it has bee The following example is a tip calculator that calculates an 18% tip and uses the method to display the amount of the original charge, the amount of the tip, and the total amount. The example is a console application that requires the user to supply the amount of the original charge as a command-line parameter. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.WriteLine/CS/tipcalc.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/tipcalc.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/tipcalc.vb" id="Snippet1"::: ]]> @@ -5886,6 +5955,7 @@ This method can be used to reacquire the standard output stream after it has bee The following example is a tip calculator that calculates an 18% tip and uses the method to display the amount of the original charge, the amount of the tip, and the total amount. The example is a console application that requires the user to supply the amount of the original charge as a command-line parameter. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.WriteLine/CS/tipcalc.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/tipcalc.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/tipcalc.vb" id="Snippet1"::: ]]> @@ -5948,6 +6018,7 @@ This method can be used to reacquire the standard output stream after it has bee The following example is a tip calculator that calculates an 18% tip and uses the method to display the amount of the original charge, the amount of the tip, and the total amount. The example is a console application that requires the user to supply the amount of the original charge as a command-line parameter. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.WriteLine/CS/tipcalc.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/tipcalc.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/tipcalc.vb" id="Snippet1"::: ]]> @@ -6010,6 +6081,7 @@ This method can be used to reacquire the standard output stream after it has bee The following example is a tip calculator that calculates an 18% tip and uses the method to display the amount of the original charge, the amount of the tip, and the total amount. The example is a console application that requires the user to supply the amount of the original charge as a command-line parameter. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.WriteLine/CS/tipcalc.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/tipcalc.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/tipcalc.vb" id="Snippet1"::: ]]> @@ -6074,6 +6146,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console.WriteLine/CPP/writeline_obj1.cpp" id="Snippet3"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.WriteLine/CS/writeline_obj1.cs" interactive="try-dotnet-method" id="Snippet3"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/writeline_obj1.fs" id="Snippet3"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/writeline_obj1.vb" id="Snippet3"::: ]]> @@ -6136,6 +6209,7 @@ This method can be used to reacquire the standard output stream after it has bee The following example is a tip calculator that calculates an 18% tip and uses the method to display the amount of the original charge, the amount of the tip, and the total amount. The example is a console application that requires the user to supply the amount of the original charge as a command-line parameter. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.WriteLine/CS/tipcalc.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/tipcalc.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/tipcalc.vb" id="Snippet1"::: ]]> @@ -6200,6 +6274,7 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Console.WriteLine/CPP/newline1.cpp" id="Snippet2"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.WriteLine/CS/newline1.cs" interactive="try-dotnet-method" id="Snippet2"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/newline1.fs" id="Snippet2"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/newline1.vb" id="Snippet2"::: ]]> @@ -6268,6 +6343,7 @@ This method can be used to reacquire the standard output stream after it has bee The following example is a tip calculator that calculates an 18% tip and uses the method to display the amount of the original charge, the amount of the tip, and the total amount. The example is a console application that requires the user to supply the amount of the original charge as a command-line parameter. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.WriteLine/CS/tipcalc.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/tipcalc.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/tipcalc.vb" id="Snippet1"::: ]]> @@ -6336,6 +6412,7 @@ This method can be used to reacquire the standard output stream after it has bee The following example is a tip calculator that calculates an 18% tip and uses the method to display the amount of the original charge, the amount of the tip, and the total amount. The example is a console application that requires the user to supply the amount of the original charge as a command-line parameter. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.WriteLine/CS/tipcalc.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/tipcalc.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/tipcalc.vb" id="Snippet1"::: ]]> @@ -6417,11 +6494,13 @@ This method can be used to reacquire the standard output stream after it has bee The following example calls the method to display five randomly generated values. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.WriteLine/CS/WriteLine6.cs" interactive="try-dotnet-method" id="Snippet6"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/WriteLine6.fs" id="Snippet6"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/WriteLine6.vb" id="Snippet6"::: The following example calls the method to display the current date. Note that the format item in the `format` argument uses the "D" [standard date and time format string](/dotnet/standard/base-types/standard-date-and-time-format-strings) to display the date in the long date format of the current culture. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.WriteLine/CS/WriteLine7.cs" id="Snippet7"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/WriteLine7.fs" id="Snippet7"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/WriteLine7.vb" id="Snippet7"::: ]]> @@ -6516,11 +6595,13 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.writelineFmt1/cpp/wl.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.writelineFmt1/cs/wl.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.writelineFmt1/fs/wl.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.writelineFmt1/vb/wl.vb" id="Snippet1"::: The following example is a tip calculator that calculates an 18% tip and uses the method to display the amount of the original charge, the amount of the tip, and the total amount. The example is a console application that requires the user to supply the amount of the original charge as a command-line parameter. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.WriteLine/CS/tipcalc.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/tipcalc.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/tipcalc.vb" id="Snippet1"::: ]]> @@ -6677,11 +6758,13 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.writelineFmt1/cpp/wl.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.writelineFmt1/cs/wl.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.writelineFmt1/fs/wl.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.writelineFmt1/vb/wl.vb" id="Snippet1"::: The following example is a tip calculator that calculates an 18% tip and uses the method to display the amount of the original charge, the amount of the tip, and the total amount. The example is a console application that requires the user to supply the amount of the original charge as a command-line parameter. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.WriteLine/CS/tipcalc.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/tipcalc.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/tipcalc.vb" id="Snippet1"::: ]]> @@ -6773,11 +6856,13 @@ This method can be used to reacquire the standard output stream after it has bee :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.writelineFmt1/cpp/wl.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.writelineFmt1/cs/wl.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.writelineFmt1/fs/wl.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.writelineFmt1/vb/wl.vb" id="Snippet1"::: The following example is a tip calculator that calculates an 18% tip and uses the method to display the amount of the original charge, the amount of the tip, and the total amount. The example is a console application that requires the user to supply the amount of the original charge as a command-line parameter. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Console.WriteLine/CS/tipcalc.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/tipcalc.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/tipcalc.vb" id="Snippet1"::: ]]> From 3740ea6f24539591bb0876c863ac5e01c43c54f6 Mon Sep 17 00:00:00 2001 From: albert-du <52804499+albert-du@users.noreply.github.com> Date: Wed, 29 Dec 2021 15:42:30 -0800 Subject: [PATCH 2/3] fix build removes redundant project files, reformats snippets to build correctly --- .../system.console.class.unsafe/fs/fs.fsproj | 9 -- .../system.console.class/fs/example3.fs | 20 ++-- .../system.console.class/fs/example3.fsproj | 12 --- .../system.console.class/fs/fontlink1.fs | 93 +++++++++---------- .../system.console.class/fs/fontlink1.fsproj | 16 ---- .../system.console.class/fs/normalize1.fs | 22 ++--- .../system.console.class/fs/normalize1.fsproj | 12 --- .../system.console.class/fs/unicode1.fs | 28 +++--- .../system.console.class/fs/unicode1.fsproj | 12 --- 9 files changed, 77 insertions(+), 147 deletions(-) delete mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class.unsafe/fs/fs.fsproj delete mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/example3.fsproj delete mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/fontlink1.fsproj delete mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/normalize1.fsproj delete mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/unicode1.fsproj diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class.unsafe/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class.unsafe/fs/fs.fsproj deleted file mode 100644 index 1d96cd521a2..00000000000 --- a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class.unsafe/fs/fs.fsproj +++ /dev/null @@ -1,9 +0,0 @@ - - - Exe - net6.0 - - - - - \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/example3.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/example3.fs index c62b49a0ab0..318c502d452 100644 --- a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/example3.fs +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/example3.fs @@ -32,7 +32,7 @@ let displayRange (start: uint) (``end``: uint) = (String.Format("0x{0:X5} is outside the upper range of Unicode code points (0x{0:X5})", ``end``, upperRange)) // Since we're using 21-bit code points, we can't use U+D800 to U+DFFF. - if ((start < surrogateStart && ``end`` > surrogateStart) || (start >= surrogateStart && start <= surrogateEnd)) then + if (start < surrogateStart && ``end`` > surrogateStart) || (start >= surrogateStart && start <= surrogateEnd) then raise (ArgumentException (String.Format @@ -53,13 +53,13 @@ let displayRange (start: uint) (``end``: uint) = printf " %c " (Convert.ToChar 0x20) else // the cast to int is safe, since we know that val <= upperRange. - let chars = Char.ConvertFromUtf32((int) cur) + let chars = Char.ConvertFromUtf32(int cur) // Display a space for code points that are not valid characters. - if CharUnicodeInfo.GetUnicodeCategory(chars.[0]) = UnicodeCategory.OtherNotAssigned then + if CharUnicodeInfo.GetUnicodeCategory(chars[0]) = UnicodeCategory.OtherNotAssigned then printf " %c " (Convert.ToChar 0x20) else // Display a space for code points in the private use area. - if CharUnicodeInfo.GetUnicodeCategory(chars.[0]) = UnicodeCategory.PrivateUse then + if CharUnicodeInfo.GetUnicodeCategory(chars[0]) = UnicodeCategory.PrivateUse then printf " %c " (Convert.ToChar 0x20) else if chars.Length > 1 && CharUnicodeInfo.GetUnicodeCategory(chars, 0) = UnicodeCategory.OtherNotAssigned then @@ -89,8 +89,8 @@ let main args = | 2 -> Some {| setOutputEncodingToUnicode = true - rangeStart = uint.Parse(args.[0], NumberStyles.HexNumber) - rangeEnd = uint.Parse(args.[1], NumberStyles.HexNumber) |} + rangeStart = uint.Parse(args[0], NumberStyles.HexNumber) + rangeEnd = uint.Parse(args[1], NumberStyles.HexNumber) |} | 3 -> let parseHexNumberOrThrow (value: string) parameterName = (uint.TryParse(value, NumberStyles.HexNumber, null)) @@ -100,16 +100,16 @@ let main args = | (true, value) -> value let setOutputEncodingToUnicode = - match bool.TryParse args.[2] with + match bool.TryParse args[2] with | true, value -> value | false, _ -> true Some {| setOutputEncodingToUnicode = setOutputEncodingToUnicode - rangeStart = parseHexNumberOrThrow args.[0] "rangeStart" - rangeEnd = parseHexNumberOrThrow args.[1] "rangeEnd" |} + rangeStart = parseHexNumberOrThrow args[0] "rangeStart" + rangeEnd = parseHexNumberOrThrow args[1] "rangeEnd" |} | _ -> - printfn "Usage: %s <%s> <%s> [%s]" (Environment.GetCommandLineArgs().[0]) "startingCodePointInHex" + printfn "Usage: %s <%s> <%s> [%s]" (Environment.GetCommandLineArgs()[0]) "startingCodePointInHex" "endingCodePointInHex" "" None diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/example3.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/example3.fsproj deleted file mode 100644 index ca53cd83fcd..00000000000 --- a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/example3.fsproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - Exe - netcoreapp3.0 - - - - - - - diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/fontlink1.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/fontlink1.fs index 4db57013e4a..51cd7c52b65 100644 --- a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/fontlink1.fs +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/fontlink1.fs @@ -1,57 +1,54 @@ -// -module Example +module fontlink1 +// open System open Microsoft.Win32 -[] -let main argv = - let valueName = "Lucida Console" - let newFont = "simsun.ttc,SimSun" +let valueName = "Lucida Console" +let newFont = "simsun.ttc,SimSun" + +let key = + Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink", true) +if isNull key then + printfn "Font linking is not enabled." +else + // Determine if the font is a base font. + let names = key.GetValueNames() + + let (fonts, kind, toAdd) = + if names |> Array.exists (fun s -> s.Equals(valueName, StringComparison.OrdinalIgnoreCase)) then + // Get the value's type. + let kind = key.GetValueKind(valueName) + + // Type should be RegistryValueKind.MultiString, but we can't be sure. + let fonts = + match kind with + | RegistryValueKind.String -> [| key.GetValue(valueName) :?> string |] + | RegistryValueKind.MultiString -> (key.GetValue(valueName) :?> string array) + | _ -> [||] + + // Determine whether SimSun is a linked font. + let toAdd = + not (fonts |> Array.exists (fun s -> s.IndexOf("SimSun", StringComparison.OrdinalIgnoreCase) >= 0)) + + (fonts, kind, toAdd) + else + // Font is not a base font. + ([||], RegistryValueKind.Unknown, true) + + if toAdd then + // Font is not a linked font. + let newFonts = Array.append fonts [| newFont |] - let key = - Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink", true) - if isNull key then - printfn "Font linking is not enabled." + // Change REG_SZ to REG_MULTI_SZ. + if kind = RegistryValueKind.String then key.DeleteValue(valueName, false) + + key.SetValue(valueName, newFonts, RegistryValueKind.MultiString) + printfn "SimSun added to the list of linked fonts." else - // Determine if the font is a base font. - let names = key.GetValueNames() - - let (fonts, kind, toAdd) = - if names |> Array.exists (fun s -> s.Equals(valueName, StringComparison.OrdinalIgnoreCase)) then - // Get the value's type. - let kind = key.GetValueKind(valueName) - - // Type should be RegistryValueKind.MultiString, but we can't be sure. - let fonts = - match kind with - | RegistryValueKind.String -> [| key.GetValue(valueName) :?> string |] - | RegistryValueKind.MultiString -> (key.GetValue(valueName) :?> string array) - | _ -> [||] - - // Determine whether SimSun is a linked font. - let toAdd = - not (fonts |> Array.exists (fun s -> s.IndexOf("SimSun", StringComparison.OrdinalIgnoreCase) >= 0)) - - (fonts, kind, toAdd) - else - // Font is not a base font. - ([||], RegistryValueKind.Unknown, true) - - if toAdd then - // Font is not a linked font. - let newFonts = Array.append fonts [| newFont |] - - // Change REG_SZ to REG_MULTI_SZ. - if kind = RegistryValueKind.String then key.DeleteValue(valueName, false) - - key.SetValue(valueName, newFonts, RegistryValueKind.MultiString) - printfn "SimSun added to the list of linked fonts." - else - printfn "Font is already linked." + printfn "Font is already linked." + +if not (isNull key) then key.Close() - if not (isNull key) then key.Close() - 0 - // diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/fontlink1.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/fontlink1.fsproj deleted file mode 100644 index d3d4dac04e9..00000000000 --- a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/fontlink1.fsproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - Exe - netcoreapp3.0 - - - - - - - - - - - diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/normalize1.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/normalize1.fs index ca9b89b159a..bc7130d1304 100644 --- a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/normalize1.fs +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/normalize1.fs @@ -1,18 +1,16 @@ -// -module Example +module normalize1 -open System; +// +open System -[] -let main argv = - let chars = [| '\u0061'; '\u0308' |] +let chars = [| '\u0061'; '\u0308' |] + +let combining = String chars +Console.WriteLine combining + +let combining2 = combining.Normalize() +Console.WriteLine combining2 - let combining = String(chars) - Console.WriteLine(combining) - - let combining = combining.Normalize() - Console.WriteLine(combining) - 0 // The example displays the following output: // a" diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/normalize1.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/normalize1.fsproj deleted file mode 100644 index 7447da85348..00000000000 --- a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/normalize1.fsproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - Exe - netcoreapp3.0 - - - - - - - diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/unicode1.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/unicode1.fs index 9af6d6ceb41..f1c843998df 100644 --- a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/unicode1.fs +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/unicode1.fs @@ -1,23 +1,19 @@ -// -module Example - +module unicode1 +// open System -[] -let main argv = - // Create a char List for the modern Cyrillic alphabet, - // from U+0410 to U+044F. - let chars = - [ for codePoint in 0x0410 .. 0x044F do - Convert.ToChar(codePoint) ] +// Create a char List for the modern Cyrillic alphabet, +// from U+0410 to U+044F. +let chars = + [ for codePoint in 0x0410 .. 0x044F do + Convert.ToChar codePoint ] - printfn "Current code page: %i\n" Console.OutputEncoding.CodePage - // Display the characters. - for ch in chars do - printf "%c " ch - if (Console.CursorLeft) >= 70 then Console.WriteLine() +printfn "Current code page: %i\n" Console.OutputEncoding.CodePage +// Display the characters. +for ch in chars do + printf "%c " ch + if Console.CursorLeft >= 70 then Console.WriteLine() - 0 // The example displays the following output: // Current code page: 437 // diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/unicode1.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/unicode1.fsproj deleted file mode 100644 index 09ef11cd987..00000000000 --- a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/unicode1.fsproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - Exe - netcoreapp3.0 - - - - - - - From 45d11ec7f46475a1781fad0c1aee5f2d00ed8880 Mon Sep 17 00:00:00 2001 From: albert-du <52804499+albert-du@users.noreply.github.com> Date: Fri, 31 Dec 2021 16:29:56 -0800 Subject: [PATCH 3/3] Additional snippets Adds snippets for Console related types * ConsoleCancelEventargs * ConsoleCancelEventHandler * ConsoleColor * ConsoleKey * ConsoleKeyInfo * ConsoleModifiers * ConsoleSpecialKey --- .../system.ConsoleKey/fs/ConsoleKey1.fs | 59 ++++++++++++++ .../system.ConsoleKey/fs/fs.fsproj | 9 +++ .../system.ConsoleKeyInfo.Equals/fs/equals.fs | 80 +++++++++++++++++++ .../system.ConsoleKeyInfo.Equals/fs/fs.fsproj | 9 +++ .../fs/fs.fsproj | 9 +++ .../fs/hash.fs | 64 +++++++++++++++ .../fs/fs.fsproj | 9 +++ .../fs/keychar1.fs | 46 +++++++++++ xml/System/ConsoleCancelEventArgs.xml | 3 + xml/System/ConsoleCancelEventHandler.xml | 1 + xml/System/ConsoleColor.xml | 1 + xml/System/ConsoleKey.xml | 1 + xml/System/ConsoleKeyInfo.xml | 6 ++ xml/System/ConsoleModifiers.xml | 1 + xml/System/ConsoleSpecialKey.xml | 1 + 15 files changed, 299 insertions(+) create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKey/fs/ConsoleKey1.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKey/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.Equals/fs/equals.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.Equals/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.GetHashcode/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.GetHashcode/fs/hash.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolekeyinfo.keychar/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolekeyinfo.keychar/fs/keychar1.fs diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKey/fs/ConsoleKey1.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKey/fs/ConsoleKey1.fs new file mode 100644 index 00000000000..680cbb0bd1a --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKey/fs/ConsoleKey1.fs @@ -0,0 +1,59 @@ +// +open System +open System.Text + +let mutable input = Unchecked.defaultof + +while input.Key <> ConsoleKey.Escape do + printfn "Press a key, together with Alt, Ctrl, or Shift." + printfn "Press Esc to exit." + input <- Console.ReadKey true + + let output = StringBuilder $"You pressed {input.Key}" + let mutable modifiers = false + + if input.Modifiers &&& ConsoleModifiers.Alt = ConsoleModifiers.Alt then + output.Append ", together with {ConsoleModifiers.Alt}" |> ignore + modifiers <- true + + if input.Modifiers &&& ConsoleModifiers.Control = ConsoleModifiers.Control then + if modifiers then + output.Append " and " |> ignore + else + output.Append ", together with " |> ignore + modifiers <- true + output.Append(string ConsoleModifiers.Control) |> ignore + + if input.Modifiers &&& ConsoleModifiers.Shift = ConsoleModifiers.Shift then + if modifiers then + output.Append " and " |> ignore + else + output.Append ", together with " |> ignore + modifiers <- true + output.Append(string ConsoleModifiers.Shift) |> ignore + output.Append "." |> ignore + + printfn $"{output}\n" + + +// The output from a sample console session might appear as follows: +// Press a key, along with Alt, Ctrl, or Shift. +// Press Esc to exit. +// You pressed D. +// +// Press a key, along with Alt, Ctrl, or Shift. +// Press Esc to exit. +// You pressed X, along with Shift. +// +// Press a key, along with Alt, Ctrl, or Shift. +// Press Esc to exit. +// You pressed L, along with Control and Shift. +// +// Press a key, along with Alt, Ctrl, or Shift. +// Press Esc to exit. +// You pressed P, along with Alt and Control and Shift. +// +// Press a key, along with Alt, Ctrl, or Shift. +// Press Esc to exit. +// You pressed Escape. +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKey/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKey/fs/fs.fsproj new file mode 100644 index 00000000000..13149209d18 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKey/fs/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.Equals/fs/equals.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.Equals/fs/equals.fs new file mode 100644 index 00000000000..450f4746269 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.Equals/fs/equals.fs @@ -0,0 +1,80 @@ +// +// This example demonstrates the ConsoleKeyInfo.Equals() method. + +open System +open System.Text + +// The keyCombination function creates a string that specifies what +// key and what combination of shift, CTRL, and ALT modifier keys +// were pressed simultaneously. +let keyCombination (sourceCki: ConsoleKeyInfo) = + let sb = StringBuilder() + sb.Length <- 0 + if int sourceCki.Modifiers <> 0 then + if int (sourceCki.Modifiers &&& ConsoleModifiers.Alt) <> 0 then + sb.Append "ALT+" |> ignore + if int (sourceCki.Modifiers &&& ConsoleModifiers.Shift) <> 0 then + sb.Append "SHIFT+" |> ignore + if int (sourceCki.Modifiers &&& ConsoleModifiers.Control) <> 0 then + sb.Append "CTL+" |> ignore + + sourceCki.Key + |> string + |> sb.Append + |> string + +// +// The Console.TreatControlCAsInput property prevents this example from +// ending if you press CTL+C, however all other operating system keys and +// shortcuts, such as ALT+TAB or the Windows Logo key, are still in effect. +// +Console.TreatControlCAsInput <- true + +let mutable cki1 = Unchecked.defaultof +let mutable cki2 = Unchecked.defaultof + +// Request that the user enter two key presses. A key press and any +// combination shift, CTRL, and ALT modifier keys is permitted. +while cki1.Key <> ConsoleKey.Escape do + printf "\nEnter a key ......... " + cki1 <- Console.ReadKey false + printf "\nEnter another key ... " + cki2 <- Console.ReadKey false + printfn "" + + let key1 = keyCombination cki1 + let key2 = keyCombination cki2 + let equalValue = + if cki1.Equals cki2 then "" + else "not " + + printfn $"The {key1} and {key2} keys are {equalValue}equal." + + printfn "Press the escape key (ESC) to quit, or any other key to continue." + cki1 <- Console.ReadKey true + +// Note: This example requires the Escape (Esc) key. + + +// This example produces results similar to the following output: +// +// Enter a key ......... a +// Enter another key ... a +// The A and A keys are equal. +// Press the escape key (ESC) to quit, or any other key to continue. +// +// Enter a key ......... a +// Enter another key ... A +// The A and SHIFT+A keys are not equal. +// Press the escape key (ESC) to quit, or any other key to continue. +// +// Enter a key ......... S +// Enter another key ... +// The ALT+SHIFT+S and ALT+CTL+F keys are not equal. +// Press the escape key (ESC) to quit, or any other key to continue. +// +// Enter a key ......... +// Enter another key ... +// The UpArrow and UpArrow keys are equal. +// Press the escape key (ESC) to quit, or any other key to continue. +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.Equals/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.Equals/fs/fs.fsproj new file mode 100644 index 00000000000..07e65f2e2c2 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.Equals/fs/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.GetHashcode/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.GetHashcode/fs/fs.fsproj new file mode 100644 index 00000000000..24cd3bcec83 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.GetHashcode/fs/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.GetHashcode/fs/hash.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.GetHashcode/fs/hash.fs new file mode 100644 index 00000000000..236a152a12d --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.GetHashcode/fs/hash.fs @@ -0,0 +1,64 @@ +// +// This example demonstrates the ConsoleKeyInfo.GetHashCode() method. + +open System +open System.Text + +// The keyCombination function creates a string that specifies what +// key and what combination of shift, CTRL, and ALT modifier keys +// were pressed simultaneously. +let keyCombination (sourceCki: ConsoleKeyInfo) = + let sb = StringBuilder() + sb.Length <- 0 + if int sourceCki.Modifiers <> 0 then + if int (sourceCki.Modifiers &&& ConsoleModifiers.Alt) <> 0 then + sb.Append "ALT+" |> ignore + if int (sourceCki.Modifiers &&& ConsoleModifiers.Shift) <> 0 then + sb.Append "SHIFT+" |> ignore + if int (sourceCki.Modifiers &&& ConsoleModifiers.Control) <> 0 then + sb.Append "CTL+" |> ignore + + sourceCki.Key + |> string + |> sb.Append + |> string + +// +// The Console.TreatControlCAsInput property prevents this example from +// ending if you press CTL+C, however all other operating system keys and +// shortcuts, such as ALT+TAB or the Windows Logo key, are still in effect. +// +Console.TreatControlCAsInput <- true + +let mutable cki1 = Unchecked.defaultof + +// Request that the user enter two key presses. A key press and any +// combination shift, CTRL, and ALT modifier keys is permitted. +while cki1.Key <> ConsoleKey.Escape do + printf "\nEnter a key ......... " + cki1 <- Console.ReadKey false + printfn "" + + let key1 = keyCombination cki1 + let hashCode = cki1.GetHashCode() + printfn $"The hash code for the {key1} key is {hashCode}." + + printfn "Press the escape key (ESC) to quit, or any other key to continue." + cki1 <- Console.ReadKey true + +// Note: This example requires the Escape (Esc) key. +// +// This example produces results similar to the following output: +// +// Enter a key ......... a +// The hash code for the A key is 97. +// Press the escape key (ESC) to quit, or any other key to continue. +// +// Enter a key ......... S +// The hash code for the SHIFT+S key is 83. +// Press the escape key (ESC) to quit, or any other key to continue. +// +// Enter a key ......... +// The hash code for the ALT+SHIFT+CTL+J key is 7. +// Press the escape key (ESC) to quit, or any other key to continue. +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolekeyinfo.keychar/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolekeyinfo.keychar/fs/fs.fsproj new file mode 100644 index 00000000000..9824c18e926 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolekeyinfo.keychar/fs/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolekeyinfo.keychar/fs/keychar1.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolekeyinfo.keychar/fs/keychar1.fs new file mode 100644 index 00000000000..cc3aa1d5992 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolekeyinfo.keychar/fs/keychar1.fs @@ -0,0 +1,46 @@ +// +open System + +// Configure console. +Console.TreatControlCAsInput <- true + +printfn "Enter a string. Press or Esc to exit." + +let mutable inputString = String.Empty +let mutable keyInfo = Unchecked.defaultof + +while keyInfo.Key <> ConsoleKey.Enter && keyInfo.Key <> ConsoleKey.Escape do + keyInfo <- Console.ReadKey true + + // Ignore if Alt or Ctrl is pressed. + if keyInfo.Modifiers &&& ConsoleModifiers.Alt <> ConsoleModifiers.Alt && + keyInfo.Modifiers &&& ConsoleModifiers.Control <> ConsoleModifiers.Control && + // Ignore if KeyChar value is \u0000. + keyInfo.KeyChar <> '\u0000' && + // Ignore tab key. + keyInfo.Key <> ConsoleKey.Tab then + + // Handle backspace. + if keyInfo.Key = ConsoleKey.Backspace then + // Are there any characters to erase? + if inputString.Length >= 1 then + // Determine where we are in the console buffer. + let cursorCol = Console.CursorLeft - 1 + let oldLength = inputString.Length + let extraRows = oldLength / 80 + + inputString <- inputString.Substring(0, oldLength - 1) + Console.CursorLeft <- 0 + Console.CursorTop <- Console.CursorTop - extraRows + printf $"{inputString + String(' ', oldLength - inputString.Length)}" + Console.CursorLeft <- cursorCol + else + // Handle key by adding it to input string. + printf $"{keyInfo.KeyChar}" + inputString <- inputString + string keyInfo.KeyChar + +printfn $""" + +You entered: + {if String.IsNullOrEmpty inputString then "" else inputString}""" +// \ No newline at end of file diff --git a/xml/System/ConsoleCancelEventArgs.xml b/xml/System/ConsoleCancelEventArgs.xml index d05332b7112..d2d829c0923 100644 --- a/xml/System/ConsoleCancelEventArgs.xml +++ b/xml/System/ConsoleCancelEventArgs.xml @@ -55,6 +55,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.cancelkeypress/cpp/ckp.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.cancelkeypress/cs/ckp.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.cancelkeypress/fs/ckp.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.cancelkeypress/vb/ckp.vb" id="Snippet1"::: ]]> @@ -111,6 +112,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.cancelkeypress/cpp/ckp.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.cancelkeypress/cs/ckp.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.cancelkeypress/fs/ckp.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.cancelkeypress/vb/ckp.vb" id="Snippet1"::: ]]> @@ -166,6 +168,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.cancelkeypress/cpp/ckp.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.cancelkeypress/cs/ckp.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.cancelkeypress/fs/ckp.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.cancelkeypress/vb/ckp.vb" id="Snippet1"::: ]]> diff --git a/xml/System/ConsoleCancelEventHandler.xml b/xml/System/ConsoleCancelEventHandler.xml index 71f9e8e90f9..0867766e7a6 100644 --- a/xml/System/ConsoleCancelEventHandler.xml +++ b/xml/System/ConsoleCancelEventHandler.xml @@ -57,6 +57,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.cancelkeypress/cpp/ckp.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.cancelkeypress/cs/ckp.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.cancelkeypress/fs/ckp.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.cancelkeypress/vb/ckp.vb" id="Snippet1"::: ]]> diff --git a/xml/System/ConsoleColor.xml b/xml/System/ConsoleColor.xml index 6fd898e6422..30c28f550d9 100644 --- a/xml/System/ConsoleColor.xml +++ b/xml/System/ConsoleColor.xml @@ -48,6 +48,7 @@ The following example saves the values of the enumeration to an array and stores the current values of the and properties to variables. It then changes the foreground color to each color in the enumeration except to the color that matches the current background, and it changes the background color to each color in the enumeration except to the color that matches the current foreground. (If the foreground color is the same as the background color, the text isn't visible.) Finally, it calls the method to restore the original console colors. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.consolecolor/cs/foregroundcolor3.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolecolor/fs/foregroundcolor3.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.consolecolor/vb/foregroundcolor3.vb" id="Snippet1"::: ]]> diff --git a/xml/System/ConsoleKey.xml b/xml/System/ConsoleKey.xml index 2b7cf781fd5..e68e0a92d2c 100644 --- a/xml/System/ConsoleKey.xml +++ b/xml/System/ConsoleKey.xml @@ -54,6 +54,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.ConsoleKey/cpp/consolekey.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.ConsoleKey/cs/ConsoleKey1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKey/fs/ConsoleKey1.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.ConsoleKey/vb/ConsoleKey1.vb" id="Snippet1"::: ]]> diff --git a/xml/System/ConsoleKeyInfo.xml b/xml/System/ConsoleKeyInfo.xml index 52960a54863..aa97b69cdfc 100644 --- a/xml/System/ConsoleKeyInfo.xml +++ b/xml/System/ConsoleKeyInfo.xml @@ -69,6 +69,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.readkey1/CPP/rk.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.readkey1/CS/rk.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.readkey1/FS/rk.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.readkey1/VB/rk.vb" id="Snippet1"::: ]]> @@ -254,6 +255,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.Equals/cpp/consolekeyinfo.equals.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.Equals/cs/equals.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.Equals/fs/equals.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.ConsoleKeyInfo.Equals/vb/equals.vb" id="Snippet1"::: ]]> @@ -308,6 +310,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.GetHashcode/cpp/hash.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.GetHashcode/cs/hash.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.GetHashcode/fs/hash.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.ConsoleKeyInfo.GetHashcode/vb/hash.vb" id="Snippet1"::: ]]> @@ -356,6 +359,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.readkey1/CPP/rk.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.readkey1/CS/rk.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.readkey1/FS/rk.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.readkey1/VB/rk.vb" id="Snippet1"::: ]]> @@ -408,6 +412,7 @@ The following example uses the property to add the characters input by the user into a string. The example ignores special keys other than **ENTER**, **ESC**, and **BACKSPACE**. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.consolekeyinfo.keychar/cs/keychar1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.consolekeyinfo.keychar/fs/keychar1.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.consolekeyinfo.keychar/vb/keychar1.vb" id="Snippet1"::: ]]> @@ -456,6 +461,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.readkey1/CPP/rk.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.readkey1/CS/rk.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.readkey1/FS/rk.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.readkey1/VB/rk.vb" id="Snippet1"::: ]]> diff --git a/xml/System/ConsoleModifiers.xml b/xml/System/ConsoleModifiers.xml index 2df8d0087a4..ad201ef928f 100644 --- a/xml/System/ConsoleModifiers.xml +++ b/xml/System/ConsoleModifiers.xml @@ -60,6 +60,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.readkey1/CPP/rk.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.readkey1/CS/rk.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.readkey1/FS/rk.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.readkey1/VB/rk.vb" id="Snippet1"::: ]]> diff --git a/xml/System/ConsoleSpecialKey.xml b/xml/System/ConsoleSpecialKey.xml index 034878062f6..65dceb009cf 100644 --- a/xml/System/ConsoleSpecialKey.xml +++ b/xml/System/ConsoleSpecialKey.xml @@ -56,6 +56,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/console.cancelkeypress/cpp/ckp.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/console.cancelkeypress/cs/ckp.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/console.cancelkeypress/fs/ckp.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/console.cancelkeypress/vb/ckp.vb" id="Snippet1"::: ]]>