From 669e53a5cac6f1abfdeb70818c59827426adacc9 Mon Sep 17 00:00:00 2001 From: albert-du <52804499+albert-du@users.noreply.github.com> Date: Wed, 8 Dec 2021 20:13:13 -0800 Subject: [PATCH] Add snippets --- .../VS_Snippets_CLR/Int16_Equals/FS/fs.fsproj | 9 ++ .../Int16_Equals/FS/int16_equals.fs | 23 ++++ .../system.Int16.MaxValue/fs/MaxValue.fs | 17 +++ .../system.Int16.MaxValue/fs/fs.fsproj | 9 ++ .../system.Int16.Parse/fs/Parse.fs | 122 ++++++++++++++++++ .../system.Int16.Parse/fs/Parse2.fs | 58 +++++++++ .../system.Int16.Parse/fs/fs.fsproj | 10 ++ .../system.Int16.ToString/fs/ToString1.fs | 109 ++++++++++++++++ .../system.Int16.ToString/fs/fs.fsproj | 9 ++ .../system.Int16.TryParse/fs/TryParse1.fs | 31 +++++ .../system.Int16.TryParse/fs/TryParse2.fs | 62 +++++++++ .../system.Int16.TryParse/fs/fs.fsproj | 10 ++ .../system.int16.equals/fs/equalsoverl.fs | 50 +++++++ .../system.int16.equals/fs/fs.fsproj | 9 ++ xml/System/Int16.xml | 15 +++ 15 files changed, 543 insertions(+) create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/Int16_Equals/FS/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/Int16_Equals/FS/int16_equals.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.MaxValue/fs/MaxValue.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.MaxValue/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.Parse/fs/Parse.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.Parse/fs/Parse2.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.Parse/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.ToString/fs/ToString1.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.ToString/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.TryParse/fs/TryParse1.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.TryParse/fs/TryParse2.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.TryParse/fs/fs.fsproj create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.int16.equals/fs/equalsoverl.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.int16.equals/fs/fs.fsproj diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/Int16_Equals/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/Int16_Equals/FS/fs.fsproj new file mode 100644 index 00000000000..0a430f3ee3a --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/Int16_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/Int16_Equals/FS/int16_equals.fs b/samples/snippets/fsharp/VS_Snippets_CLR/Int16_Equals/FS/int16_equals.fs new file mode 100644 index 00000000000..c94377e9f54 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/Int16_Equals/FS/int16_equals.fs @@ -0,0 +1,23 @@ +// System.Int16.Equals(Object) + +(* + The following program demonstrates the 'Equals(Object)' method + of struct 'Int16'. This compares an instance of 'Int16' with the + passed in object and returns true if they are equal. +*) + +// +let myVariable1 = 20s +let myVariable2 = 20s + +// Get and display the declaring type. +printfn $"\nType of 'myVariable1' is '{myVariable1.GetType()}' and value is: {myVariable1}" +printfn $"\nType of 'myVariable1' is '{myVariable2.GetType()}' and value is: {myVariable2}" + +// Compare 'myVariable1' instance with 'myVariable2' Object. +if myVariable1.Equals myVariable2 then + printfn "\nStructures 'myVariable1' and 'myVariable2' are equal" +else + printfn "\nStructures 'myVariable1' and 'myVariable2' are not equal" + +// diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.MaxValue/fs/MaxValue.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.MaxValue/fs/MaxValue.fs new file mode 100644 index 00000000000..6c38501eee6 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.MaxValue/fs/MaxValue.fs @@ -0,0 +1,17 @@ +// +open System + +let numbersToConvert = [ 162345L; 32183L; -54000L ] + +for number in numbersToConvert do + if number >= int64 Int16.MinValue && number <= int64 Int16.MaxValue then + let newNumber = Convert.ToInt16 number + printfn $"Successfully converted {newNumber} to an Int16." + else + printfn $"Unable to convert {number} to an Int16." + +// The example displays the following output to the console: +// Unable to convert 162345 to an Int16. +// Successfully converted 32183 to an Int16. +// Unable to convert -54000 to an Int16. +// diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.MaxValue/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.MaxValue/fs/fs.fsproj new file mode 100644 index 00000000000..1c4fa339bdd --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.MaxValue/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.Int16.Parse/fs/Parse.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.Parse/fs/Parse.fs new file mode 100644 index 00000000000..d96c88c3755 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.Parse/fs/Parse.fs @@ -0,0 +1,122 @@ +module Parse + +open System +open System.Globalization + + +let callParse1 () = + // + let value = " 12603 " + try + let number = Int16.Parse value + printfn $"Converted '{value}' to {number}." + with :? FormatException -> + printfn $"Unable to convert '{value}' to a 16-bit signed integer." + + let value = " 16,054" + try + let number = Int16.Parse value + printfn $"Converted '{value}' to {number}." + with :? FormatException -> + printfn "Unable to convert '{value}' to a 16-bit signed integer." + + let value = " -17264" + try + let number = Int16.Parse value + printfn $"Converted '{value}' to {number}." + with :? FormatException -> + printfn "Unable to convert '{value}' to a 16-bit signed integer." + + + // The example displays the following output to the console: + // Converted ' 12603 ' to 12603. + // Unable to convert ' 16,054' to a 16-bit signed integer. + // Converted ' -17264' to -17264. + // + +let callParse3 () = + // + // Parse string using "." as the thousands separator + // and " " as the decimal separator. + let value = "19 694,00" + let style = NumberStyles.AllowDecimalPoint ||| NumberStyles.AllowThousands + let provider = CultureInfo "fr-FR" + + let number = Int16.Parse(value, style, provider) + printfn $"'{value}' converted to {number}." + // Displays: + // '19 694,00' converted to 19694. + + try + let number = Int16.Parse(value, style, CultureInfo.InvariantCulture) + printfn $"'{value}' converted to {number}." + with :? FormatException -> + printfn $"Unable to parse '{value}'." + // Displays: + // Unable to parse '19 694,00'. + + // Parse string using "$" as the currency symbol for en_GB and + // en-US cultures. + let value = "$6,032.00" + let style = NumberStyles.Number ||| NumberStyles.AllowCurrencySymbol + + try + let number = Int16.Parse(value, style, CultureInfo.InvariantCulture) + printfn $"'{value}' converted to {number}." + with :? FormatException -> + printfn $"Unable to parse '{value}'." + // Displays: + // Unable to parse '$6,032.00'. + + let provider = CultureInfo "en-US" + let number = Int16.Parse(value, style, provider) + printfn $"'{value}' converted to {number}." + // Displays: + // '$6,032.00' converted to 6032. + // + + +let callParse4 () = + // + let stringToConvert = " 214 " + try + let number = Int16.Parse(stringToConvert, CultureInfo.InvariantCulture) + printfn $"Converted '{stringToConvert}' to {number}." + with + | :? FormatException -> + printfn $"Unable to parse '{stringToConvert}'." + | :? OverflowException -> + printfn $"'{stringToConvert}' is out of range of the Int16 data type." + + let stringToConvert = " + 214" + try + let number = Int16.Parse(stringToConvert, CultureInfo.InvariantCulture) + printfn $"Converted '{stringToConvert}' to {number}." + with + | :? FormatException -> + printfn $"Unable to parse '{stringToConvert}'." + | :? OverflowException -> + printfn $"'{stringToConvert}' is out of range of the Int16 data type." + + let stringToConvert = " +214 " + try + let number = Int16.Parse(stringToConvert, CultureInfo.InvariantCulture) + printfn $"Converted '{stringToConvert}' to {number}." + with + | :? FormatException -> + printfn $"Unable to parse '{stringToConvert}'." + | :? OverflowException -> + printfn $"'{stringToConvert}' is out of range of the Int16 data type." + + // The example displays the following output to the console: + // Converted ' 214 ' to 214. + // Unable to parse ' + 214'. + // Converted ' +214 ' to 214. + // + + +callParse1 () +printfn "-----" +callParse3 () +printfn "-----" +callParse4 () \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.Parse/fs/Parse2.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.Parse/fs/Parse2.fs new file mode 100644 index 00000000000..9b07b31cc5d --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.Parse/fs/Parse2.fs @@ -0,0 +1,58 @@ +// +open System +open System.Globalization + +let parseToInt16 (value: string) (style: NumberStyles) = + try + let number = Int16.Parse(value, style) + printfn $"Converted '{value}' to {number}." + with + | :? FormatException -> + printfn $"Unable to parse '{value}' with style {style}." + | :? OverflowException -> + printfn $"'{value}' is out of range of the Int16 type." + +[] +let main _ = + // Parse a number with a thousands separator (throws an exception). + let value = "14,644" + let style = NumberStyles.None + parseToInt16 value style + + let style = NumberStyles.AllowThousands + parseToInt16 value style + + // Parse a number with a thousands separator and decimal point. + let value = "14,644.00" + let style = NumberStyles.AllowThousands ||| NumberStyles.Integer ||| NumberStyles.AllowDecimalPoint + parseToInt16 value style + + // Parse a number with a fractional component (throws an exception). + let value = "14,644.001" + parseToInt16 value style + + // Parse a number in exponential notation. + let value = "145E02" + let style = style ||| NumberStyles.AllowExponent + parseToInt16 value style + + // Parse a number in exponential notation with a positive sign. + let value = "145E+02" + parseToInt16 value style + + // Parse a number in exponential notation with a negative sign + // (throws an exception). + let value = "145E-02" + parseToInt16 value style + + 0 + +// The example displays the following output to the console: +// Unable to parse '14,644' with style None. +// Converted '14,644' to 14644. +// Converted '14,644.00' to 14644. +// '14,644.001' is out of range of the Int16 type. +// Converted '145E02' to 14500. +// Converted '145E+02' to 14500. +// '145E-02' is out of range of the Int16 type. +// diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.Parse/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.Parse/fs/fs.fsproj new file mode 100644 index 00000000000..7d9850b327f --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.Parse/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.Int16.ToString/fs/ToString1.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.ToString/fs/ToString1.fs new file mode 100644 index 00000000000..eb1a6b90e2d --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.ToString/fs/ToString1.fs @@ -0,0 +1,109 @@ +open System +open System.Globalization + +let callDefaultToString () = + // + let numbers = [ 0s; 14624s; 13982s; Int16.MaxValue; Int16.MinValue; -16667s ] + + for number in numbers do + printfn $"{number.ToString()}" + + // The example displays the following output to the console: + // 0 + // 14624 + // 13982 + // 32767 + // -32768 + // -16667 + // + +let callToStringWithProvider () = + // + let numbers = [ -23092s; 0s; 14894s; Int16.MaxValue ] + let providers = + [ CultureInfo "en-us" + CultureInfo "fr-fr" + CultureInfo "de-de" + CultureInfo "es-es" ] + + for int16Value in numbers do + for provider in providers do + printf $"{int16Value.ToString provider, 6} ({provider.Name}) " + + printfn "" + + // The example displays the following output to the console: + // -23092 (en-US) -23092 (fr-FR) -23092 (de-DE) -23092 (es-ES) + // 0 (en-US) 0 (fr-FR) 0 (de-DE) 0 (es-ES) + // 14894 (en-US) 14894 (fr-FR) 14894 (de-DE) 14894 (es-ES) + // 32767 (en-US) 32767 (fr-FR) 32767 (de-DE) 32767 (es-ES) + // + +let callToStringWithSpecifiers () = + // + let values = [| -23805s; 32194s |] + let formats = + [ "C4"; "D6"; "e1"; "E2"; "F1"; "G"; "N1" + "P0"; "X4"; "000000.0000"; "##000.0" ] + for format in formats do + printfn $"'{format,2}' format specifier: {values[0].ToString format,17} {values[1].ToString format,17}" + + // The example displays the following output to the console: + // 'C4' format specifier: ($23,805.0000) $32,194.0000 + // 'D6' format specifier: -023805 032194 + // 'e1' format specifier: -2.4e+004 3.2e+004 + // 'E2' format specifier: -2.38E+004 3.22E+004 + // 'F1' format specifier: -23805.0 32194.0 + // ' G' format specifier: -23805 32194 + // 'N1' format specifier: -23,805.0 32,194.0 + // 'P0' format specifier: -2,380,500 % 3,219,400 % + // 'X4' format specifier: A303 7DC2 + // '000000.0000' format specifier: -023805.0000 032194.0000 + // '##000.0' format specifier: -23805.0 32194.0 + // + +let callToStringWithSpecifiersAndProviders () = + // + let value = 14603 + let formats = + [ "C"; "D6"; "e1"; "E2"; "F1"; "G"; "N1" + "P0"; "X4"; "000000.0000"; "##000.0" ] + let providers = + [ CultureInfo "en-us" + CultureInfo "fr-fr" + CultureInfo "de-de" + CultureInfo "es-es" ] + // Display header. + printfn $"{providers[0],24}{providers[1],14}{providers[2],14}{providers[3],14}\n" + + // Display a value using each format string. + for format in formats do + // Display the value for each provider on the same line. + printf $"{format,-12}" + for provider in providers do + printf $"{value.ToString(format, provider),12} " + printfn "" + + // The example displays the following output to the console: + // en-US fr-FR de-DE es-ES + // + // C $14,603.00 14 603,00 € 14.603,00 € 14.603,00 € + // D6 014603 014603 014603 014603 + // e1 1.5e+004 1,5e+004 1,5e+004 1,5e+004 + // E2 1.46E+004 1,46E+004 1,46E+004 1,46E+004 + // F1 14603.0 14603,0 14603,0 14603,0 + // G 14603 14603 14603 14603 + // N1 14,603.0 14 603,0 14.603,0 14.603,0 + // P0 1,460,300 % 1 460 300 % 1.460.300% 1.460.300 % + // X4 390B 390B 390B 390B + // 000000.0000 014603.0000 014603,0000 014603,0000 014603,0000 + // ##000.0 14603.0 14603,0 14603,0 14603,0 + // + +callDefaultToString () +printfn "------" +callToStringWithProvider () +printfn "------" +callToStringWithSpecifiers () +printfn "------" +callToStringWithSpecifiersAndProviders () diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.ToString/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.ToString/fs/fs.fsproj new file mode 100644 index 00000000000..be7c001d084 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.ToString/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.Int16.TryParse/fs/TryParse1.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.TryParse/fs/TryParse1.fs new file mode 100644 index 00000000000..3c748c1b4cb --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.TryParse/fs/TryParse1.fs @@ -0,0 +1,31 @@ +module TryParse1 + +// +open System + +let tryToParse (value: string) = + match Int16.TryParse value with + | true, number -> printfn "Converted '{value}' to {number}." + | _ -> + let value = if isNull value then "" else value + printfn $"Attempted conversion of '{value}' failed." + +tryToParse null +tryToParse "16051" +tryToParse "9432.0" +tryToParse "16,667" +tryToParse " -322 " +tryToParse "+4302" +tryToParse "(100);" +tryToParse "01FA" + +// The example displays the following output to the console: +// Attempted conversion of '' failed. +// Converted '16051' to 16051. +// Attempted conversion of '9432.0' failed. +// Attempted conversion of '16,667' failed. +// Converted ' -322 ' to -322. +// Converted '+4302' to 4302. +// Attempted conversion of '(100)' failed. +// Attempted conversion of '01FA' failed. +// diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.TryParse/fs/TryParse2.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.TryParse/fs/TryParse2.fs new file mode 100644 index 00000000000..ce1918d53d0 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.TryParse/fs/TryParse2.fs @@ -0,0 +1,62 @@ +module TryParse2 + +// +open System +open System.Globalization + +let callTryParse (stringToConvert: string) (styles: NumberStyles) = + match Int16.TryParse(stringToConvert, styles, CultureInfo.InvariantCulture) with + | true, number -> + printfn $"Converted '{stringToConvert}' to {number}." + | _ -> + printfn $"Attempted conversion of '{stringToConvert}' failed." + +[] +let main _ = + let numericString = "10677" + let styles = NumberStyles.Integer + callTryParse numericString styles + + let numericString = "-30677" + let styles = NumberStyles.None + callTryParse numericString styles + + let numericString = "10345.00" + let styles = NumberStyles.Integer ||| NumberStyles.AllowDecimalPoint + callTryParse numericString styles + + let numericString = "10345.72"; + let styles = NumberStyles.Integer ||| NumberStyles.AllowDecimalPoint + callTryParse numericString styles + + let numericString = "22,593" + let styles = NumberStyles.Integer ||| NumberStyles.AllowThousands + callTryParse numericString styles + + let numericString = "12E-01" + let styles = NumberStyles.Integer ||| NumberStyles.AllowExponent + callTryParse numericString styles + + let numericString = "12E03" + callTryParse numericString styles + + let numericString = "80c1" + callTryParse numericString NumberStyles.HexNumber + + let numericString = "0x80C1" + callTryParse numericString NumberStyles.HexNumber + + 0 + + +// The example displays the following output to the console: +// Converted '10677' to 10677. +// Attempted conversion of '-30677' failed. +// Converted '10345.00' to 10345. +// Attempted conversion of '10345.72' failed. +// Converted '22,593' to 22593. +// Attempted conversion of '12E-01' failed. +// Converted '12E03' to 12000. +// Converted '80c1' to -32575. +// Attempted conversion of '0x80C1' failed. +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.TryParse/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.TryParse/fs/fs.fsproj new file mode 100644 index 00000000000..682586ee64a --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.TryParse/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.int16.equals/fs/equalsoverl.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.int16.equals/fs/equalsoverl.fs new file mode 100644 index 00000000000..9ee27b382b3 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.int16.equals/fs/equalsoverl.fs @@ -0,0 +1,50 @@ +// +let value = 112s + +let testObjectForEquality (obj: obj) = + printfn $"{value} ({value.GetType().Name}) = {obj} ({obj.GetType().Name}): {value.Equals obj}\n" + +let byte1 = 112uy +printfn $"value = byte1: {value.Equals(int16 byte1),15}" +testObjectForEquality byte1 + +let int1 = 112 +printfn $"value = int1: {value.Equals(int16 int1),17}" +testObjectForEquality int1 + +let sbyte1 = 112uy +printfn $"value = sbyte1: {value.Equals(int16 sbyte1),15}" +testObjectForEquality sbyte1 + +let ushort1 = 112us +printfn $"value = ushort1: {value.Equals(int16 ushort1),15}" +testObjectForEquality ushort1 + +let dec1 = 112M +printfn $"value = dec1: {value.Equals dec1,20}" +testObjectForEquality dec1 + +let dbl1 = 112.0 +printfn $"value = dbl1: {value.Equals dbl1,19}" +testObjectForEquality dbl1 + + +// The example displays the following output: +// value = byte1: True +// 112 (Int16) = 112 (Byte): False +// +// value = int1: False +// 112 (Int16) = 112 (Int32): False +// +// value = sbyte1: True +// 112 (Int16) = 112 (SByte): False +// +// value = ushort1: False +// 112 (Int16) = 112 (UInt16): False +// +// value = dec1: False +// 112 (Int16) = 112 (Decimal): False +// +// value = dbl1: False +// 112 (Int16) = 112 (Double): False +// diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.int16.equals/fs/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.int16.equals/fs/fs.fsproj new file mode 100644 index 00000000000..f1da800c5f5 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.int16.equals/fs/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file diff --git a/xml/System/Int16.xml b/xml/System/Int16.xml index ee10fb35dae..f098db9020f 100644 --- a/xml/System/Int16.xml +++ b/xml/System/Int16.xml @@ -356,6 +356,7 @@ Compiler overload resolution may account for an apparent difference in the behavior of the two method overloads. If an implicit conversion between the argument and an is defined and the argument is not typed as an , compilers perform an implicit conversion and call the method. Otherwise, they call the method, which always returns if its argument is not an value. The following example illustrates the difference in behavior between the two method overloads. In the case of the and values, the first comparison returns because the compiler automatically performs a widening conversion and calls the method, whereas the second comparison returns because the compiler calls the method. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.int16.equals/cs/equalsoverl.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.int16.equals/fs/equalsoverl.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.int16.equals/vb/equalsoverl.vb" id="Snippet1"::: @@ -414,6 +415,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/Int16_Equals/CPP/int16_equals.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/Int16_Equals/CS/int16_equals.cs" interactive="try-dotnet-method" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/Int16_Equals/FS/int16_equals.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/Int16_Equals/VB/int16_equals.vb" id="Snippet1"::: ]]> @@ -422,6 +424,7 @@ Compiler overload resolution may account for an apparent difference in the behavior of the two method overloads. If an implicit conversion between the argument and an is defined and the argument is not typed as an , compilers perform an implicit conversion and call the method. Otherwise, they call the method, which always returns if its argument is not an value. The following example illustrates the difference in behavior between the two method overloads. In the case of the and values, the first comparison returns because the compiler automatically performs a widening conversion and calls the method, whereas the second comparison returns because the compiler calls the method. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.int16.equals/cs/equalsoverl.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.int16.equals/fs/equalsoverl.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.int16.equals/vb/equalsoverl.vb" id="Snippet1"::: @@ -563,6 +566,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Int16.MaxValue/cpp/minvalue.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Int16.MaxValue/cs/MaxValue.cs" interactive="try-dotnet-method" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.MaxValue/fs/MaxValue.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Int16.MaxValue/vb/MaxValue.vb" id="Snippet1"::: ]]> @@ -623,6 +627,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Int16.MaxValue/cpp/minvalue.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Int16.MaxValue/cs/MaxValue.cs" interactive="try-dotnet-method" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.MaxValue/fs/MaxValue.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Int16.MaxValue/vb/MaxValue.vb" id="Snippet1"::: ]]> @@ -713,6 +718,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Int16.Parse/cpp/parse1.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Int16.Parse/cs/Parse.cs" interactive="try-dotnet-method" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.Parse/fs/Parse.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Int16.Parse/vb/Parse.vb" id="Snippet1"::: ]]> @@ -826,6 +832,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Int16.Parse/cpp/parse2.cpp" id="Snippet2"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Int16.Parse/cs/Parse2.cs" interactive="try-dotnet" id="Snippet2"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.Parse/fs/Parse2.fs" id="Snippet2"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Int16.Parse/vb/Parse2.vb" id="Snippet2"::: ]]> @@ -924,6 +931,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Int16.Parse/cpp/parse4.cpp" id="Snippet4"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Int16.Parse/cs/Parse.cs" interactive="try-dotnet-method" id="Snippet4"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.Parse/fs/Parse.fs" id="Snippet4"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Int16.Parse/vb/Parse.vb" id="Snippet4"::: ]]> @@ -1080,6 +1088,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Int16.Parse/cpp/parse3.cpp" id="Snippet3"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Int16.Parse/cs/Parse.cs" interactive="try-dotnet-method" id="Snippet3"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.Parse/fs/Parse.fs" id="Snippet3"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Int16.Parse/vb/Parse.vb" id="Snippet3"::: ]]> @@ -2093,6 +2102,7 @@ This member is an explicit interface member implementation. It can be used only The following example uses the method to display an array of values to the console. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Int16.ToString/cs/ToString1.cs" interactive="try-dotnet-method" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.ToString/fs/ToString1.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Int16.ToString/vb/ToString1.vb" id="Snippet1"::: ]]> @@ -2182,6 +2192,7 @@ This member is an explicit interface member implementation. It can be used only The following example iterates an array of values and displays each of them to the console by calling the method with different format providers. Because of the simple formatting defined by the default "G" format specifier, the formatted strings produced for each value are identical regardless of the value of the `provider` parameter. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Int16.ToString/cs/ToString1.cs" interactive="try-dotnet-method" id="Snippet2"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.ToString/fs/ToString1.fs" id="Snippet2"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Int16.ToString/vb/ToString1.vb" id="Snippet2"::: ]]> @@ -2262,6 +2273,7 @@ This member is an explicit interface member implementation. It can be used only The following example initializes two values and displays them to the console using each of the supported standard format strings and several custom format strings. The example is run with en-US as the current culture. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Int16.ToString/cs/ToString1.cs" id="Snippet3"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.ToString/fs/ToString1.fs" id="Snippet3"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Int16.ToString/vb/ToString1.vb" id="Snippet3"::: ]]> @@ -2358,6 +2370,7 @@ This member is an explicit interface member implementation. It can be used only The following example displays an value using each of the supported standard format strings in four different cultures. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Int16.ToString/cs/ToString1.cs" interactive="try-dotnet-method" id="Snippet4"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.ToString/fs/ToString1.fs" id="Snippet4"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Int16.ToString/vb/ToString1.vb" id="Snippet4"::: ]]> @@ -2547,6 +2560,7 @@ This member is an explicit interface member implementation. It can be used only The following example calls the method with a number of different string values. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Int16.TryParse/cs/TryParse1.cs" interactive="try-dotnet" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.TryParse/fs/TryParse1.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Int16.TryParse/vb/TryParse1.vb" id="Snippet1"::: Some of the strings that the method is unable to convert in this example are: @@ -2720,6 +2734,7 @@ This member is an explicit interface member implementation. It can be used only The following example calls the method with a number of different string values. :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Int16.TryParse/cs/TryParse2.cs" interactive="try-dotnet" id="Snippet2"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.TryParse/fs/TryParse2.fs" id="Snippet2"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Int16.TryParse/vb/TryParse2.vb" id="Snippet2"::: ]]>