diff --git a/docs/core/tools/csproj.md b/docs/core/tools/csproj.md index dba6615d68f58..1f9eadb76aa3f 100644 --- a/docs/core/tools/csproj.md +++ b/docs/core/tools/csproj.md @@ -173,7 +173,7 @@ The following example specifies the fallbacks only for the `netcoreapp2.1` targe ``` ## NuGet metadata properties -With the move to MSbuild, we have moved the input metadata that is used when packing a NuGet package from *project.json* to *.csproj* files. The inputs are MSBuild properties so they have to go within a `` group. The following is the list of properties that are used as inputs to the packing process when using the `dotnet pack` command or the `Pack` MSBuild target that is part of the SDK. +With the move to MSBuild, we have moved the input metadata that is used when packing a NuGet package from *project.json* to *.csproj* files. The inputs are MSBuild properties so they have to go within a `` group. The following is the list of properties that are used as inputs to the packing process when using the `dotnet pack` command or the `Pack` MSBuild target that is part of the SDK. ### IsPackable A Boolean value that specifies whether the project can be packed. The default value is `true`. diff --git a/docs/csharp/language-reference/compiler-options/how-to-set-environment-variables-for-the-visual-studio-command-line.md b/docs/csharp/language-reference/compiler-options/how-to-set-environment-variables-for-the-visual-studio-command-line.md index 07542b8eb6ae8..9d40f6a6001cc 100644 --- a/docs/csharp/language-reference/compiler-options/how-to-set-environment-variables-for-the-visual-studio-command-line.md +++ b/docs/csharp/language-reference/compiler-options/how-to-set-environment-variables-for-the-visual-studio-command-line.md @@ -18,7 +18,7 @@ ms.assetid: 7ec09480-5612-4f6a-8d00-ad90ea9bca5d --- # How to: Set Environment Variables for the Visual Studio Command Line -The VsDevCmd.bat file sets the appropriate environment variables to enable command-line builds. For more information about VsDevCmd.bat, see [Knowledge Base article Q248802](https://support.microsoft.com/help/248802/you-receive-the-out-of-environment-space-error-message-when-you-execut). +The VsDevCmd.bat file sets the appropriate environment variables to enable command-line builds. > [!NOTE] > The VsDevCmd.bat file is a new file delivered with Visual Studio 2017. Visual Studio 2015 and earlier versions used VSVARS32.bat for the same purpose. This file was stored in \Program Files\Microsoft Visual Studio\\*Version*\Common7\Tools or Program Files (x86)\Microsoft Visual Studio\\*Version*\Common7\Tools. @@ -35,7 +35,14 @@ If the current version of Visual Studio is installed on a computer that also has > [!CAUTION] > VsDevCmd.bat can vary from computer to computer. Do not replace a missing or damaged VsDevCmd.bat file with a VsDevCmd.bat from another computer. Instead, rerun setup to replace the missing file. - + +### Available options for VsDevCmd.BAT + +To see the available options for VsDevCmd.BAT, run the command with the `-help` option: +```console +VsDevCmd.bat -help +``` + ## See Also - [Command-line Building With csc.exe](../../../csharp/language-reference/compiler-options/command-line-building-with-csc-exe.md) diff --git a/docs/csharp/language-reference/keywords/class.md b/docs/csharp/language-reference/keywords/class.md index 9ac067f9e1fc3..d983625738c09 100644 --- a/docs/csharp/language-reference/keywords/class.md +++ b/docs/csharp/language-reference/keywords/class.md @@ -89,7 +89,7 @@ Accessing private members of `Child` from `Main` would only be possible if `Main Types declared inside a class without an access modifier default to `private`, so the data members in this example would still be `private` if the keyword were removed. -Finally, notice that for the object created using the default constructor (`child3`), the age field was initialized to zero by default. +Finally, notice that for the object created using the default constructor (`child3`), the `age` field was initialized to zero by default. ## C# language specification diff --git a/docs/csharp/language-reference/keywords/delegate.md b/docs/csharp/language-reference/keywords/delegate.md index 4401016ae3cab..a40be70512218 100644 --- a/docs/csharp/language-reference/keywords/delegate.md +++ b/docs/csharp/language-reference/keywords/delegate.md @@ -47,5 +47,6 @@ The delegate must be instantiated with a method or lambda expression that has a - [Reference Types](../../../csharp/language-reference/keywords/reference-types.md) - [Delegates](../../../csharp/programming-guide/delegates/index.md) - [Events](../../../csharp/programming-guide/events/index.md) -- [Delegates with Named vs. Anonymous Methods](../../../csharp/programming-guide/delegates/delegates-with-named-vs-anonymous-methods.md) +- [Delegates with Named vs. Anonymous Methods](../../../csharp/programming-guide/delegates/delegates-with-named-vs-anonymous-methods.md) - [Anonymous Methods](../../../csharp/programming-guide/statements-expressions-operators/anonymous-methods.md) +- [Lambda Expressions](../../../csharp/programming-guide/statements-expressions-operators/lambda-expressions.md) diff --git a/docs/csharp/language-reference/keywords/string.md b/docs/csharp/language-reference/keywords/string.md index ea6edbe19c926..a8793e30a2c75 100644 --- a/docs/csharp/language-reference/keywords/string.md +++ b/docs/csharp/language-reference/keywords/string.md @@ -52,6 +52,18 @@ string str = "test"; char x = str[2]; // x = 's'; ``` +In similar fashion, the [] operator can also be used for iterating over each character in a `string`: + +```csharp +string str = "test"; + +for (int i = 0; i < str.Length; i++) +{ + Console.Write(str[i] + " "); +} +// Output: t e s t +``` + String literals are of type `string` and can be written in two forms, quoted and @-quoted. Quoted string literals are enclosed in double quotation marks ("): ```csharp diff --git a/docs/csharp/language-reference/operators/codesnippet/CSharp/division-assignment-operator_1.cs b/docs/csharp/language-reference/operators/codesnippet/CSharp/division-assignment-operator_1.cs deleted file mode 100644 index 87df4a8209610..0000000000000 --- a/docs/csharp/language-reference/operators/codesnippet/CSharp/division-assignment-operator_1.cs +++ /dev/null @@ -1,17 +0,0 @@ - class MainClass2 - { - static void Main() - { - int a = 5; - a /= 6; - Console.WriteLine(a); - double b = 5; - b /= 6; - Console.WriteLine(b); - } - } - /* - Output: - 0 - 0.833333333333333 - */ \ No newline at end of file diff --git a/docs/csharp/language-reference/operators/codesnippet/CSharp/division-operator_1.cs b/docs/csharp/language-reference/operators/codesnippet/CSharp/division-operator_1.cs deleted file mode 100644 index e0eb5388edb24..0000000000000 --- a/docs/csharp/language-reference/operators/codesnippet/CSharp/division-operator_1.cs +++ /dev/null @@ -1,34 +0,0 @@ - class Division - { - static void Main() - { - Console.WriteLine("\nDividing 7 by 3."); - // Integer quotient is 2, remainder is 1. - Console.WriteLine("Integer quotient: {0}", 7 / 3); - Console.WriteLine("Negative integer quotient: {0}", -7 / 3); - Console.WriteLine("Remainder: {0}", 7 % 3); - // Force a floating point quotient. - float dividend = 7; - Console.WriteLine("Floating point quotient: {0}", dividend / 3); - - Console.WriteLine("\nDividing 8 by 5."); - // Integer quotient is 1, remainder is 3. - Console.WriteLine("Integer quotient: {0}", 8 / 5); - Console.WriteLine("Negative integer quotient: {0}", 8 / -5); - Console.WriteLine("Remainder: {0}", 8 % 5); - // Force a floating point quotient. - Console.WriteLine("Floating point quotient: {0}", 8 / 5.0); - } - } - // Output: - //Dividing 7 by 3. - //Integer quotient: 2 - //Negative integer quotient: -2 - //Remainder: 1 - //Floating point quotient: 2.33333333333333 - - //Dividing 8 by 5. - //Integer quotient: 1 - //Negative integer quotient: -1 - //Remainder: 3 - //Floating point quotient: 1.6 \ No newline at end of file diff --git a/docs/csharp/language-reference/operators/division-assignment-operator.md b/docs/csharp/language-reference/operators/division-assignment-operator.md index 905d69a07e9c3..df95c94244ab7 100644 --- a/docs/csharp/language-reference/operators/division-assignment-operator.md +++ b/docs/csharp/language-reference/operators/division-assignment-operator.md @@ -1,8 +1,7 @@ --- title: "/= Operator - C# Reference" ms.custom: seodec18 - -ms.date: 07/20/2015 +ms.date: 12/13/2018 f1_keywords: - "/=_CSharpKeyword" helpviewer_keywords: @@ -11,30 +10,39 @@ helpviewer_keywords: ms.assetid: 50fc02b0-ee9c-4c3e-b58d-d591282caf1c --- # /= Operator (C# Reference) -The division assignment operator. - -## Remarks - An expression using the `/=` assignment operator, such as - -```csharp -x /= y -``` - - is equivalent to - -```csharp -x = x / y -``` - - except that `x` is only evaluated once. The [/ operator](../../../csharp/language-reference/operators/division-operator.md) is predefined for numeric types to perform division. - - The `/=` operator cannot be overloaded directly, but user-defined types can overload the [/ operator](../../../csharp/language-reference/operators/division-operator.md) (see [operator](../../../csharp/language-reference/keywords/operator.md)). On all compound assignment operators, overloading the binary operator implicitly overloads the equivalent compound assignment. - -## Example - [!code-csharp[csRefOperators#5](codesnippet/CSharp/division-assignment-operator_1.cs)] - -## See Also - -- [C# Reference](../../../csharp/language-reference/index.md) -- [C# Programming Guide](../../../csharp/programming-guide/index.md) -- [C# Operators](../../../csharp/language-reference/operators/index.md) + +The division assignment operator. + +An expression using the `/=` operator, such as + +```csharp +x /= y +``` + +is equivalent to + +```csharp +x = x / y +``` + +except that `x` is only evaluated once. + +The [division operator](division-operator.md) `/` divides its first operand by its second operand. It's supported by all numeric types. + +The following example demonstrates the usage of the `/=` operator: + +[!code-csharp-interactive[divide and assign](~/samples/snippets/csharp/language-reference/operators/DivisionExamples.cs#DivisionAssignment)] + +## Operator overloadability + +If a user-defined type [overloads](../keywords/operator.md) the [division operator](division-operator.md) `/`, the division assignment operator `/=` is implicitly overloaded. A user-defined type cannot explicitly overload the division assignment operator. + +## C# language specification + +For more information, see the [Compound assignment](~/_csharplang/spec/expressions.md#compound-assignment) section of the [C# language specification](../language-specification/index.md). + +## See also + +- [C# Reference](../index.md) +- [C# Programming Guide](../../programming-guide/index.md) +- [C# Operators](index.md) diff --git a/docs/csharp/language-reference/operators/division-operator.md b/docs/csharp/language-reference/operators/division-operator.md index 05861c373715a..af19a0ddda4f2 100644 --- a/docs/csharp/language-reference/operators/division-operator.md +++ b/docs/csharp/language-reference/operators/division-operator.md @@ -1,8 +1,7 @@ --- title: "/ Operator - C# Reference" ms.custom: seodec18 - -ms.date: 04/04/2018 +ms.date: 12/13/2018 f1_keywords: - "/_CSharpKeyword" helpviewer_keywords: @@ -11,22 +10,38 @@ helpviewer_keywords: ms.assetid: d155e496-678f-4efa-bebe-2bd08da2c5af --- # / Operator (C# Reference) -The division operator (`/`) divides its first operand by its second operand. All numeric types have predefined division operators. - -## Remarks - User-defined types can overload the `/` operator (see [operator](../../../csharp/language-reference/keywords/operator.md)). An overload of the `/` operator implicitly overloads the [/= operator](division-assignment-operator.md). - - When you divide two integers, the result is always an integer. For example, the result of 7 / 3 is 2. This is not to be confused with floored division, as the `/` operator rounds towards zero: -7 / 3 is -2. - - To obtain a quotient as a rational number, use the `float`, `double`, or `decimal` types. There are many ways to convert between [built in numeric types](../../../csharp/language-reference/keywords/reference-tables-for-types.md). - - To determine the remainder, use the [remainder operator](../../../csharp/language-reference/operators/remainder-operator.md) `%`. - -## Example - [!code-csharp[csRefOperators#42](../../../csharp/language-reference/operators/codesnippet/CSharp/division-operator_1.cs)] - -## See Also - -- [C# Reference](../../../csharp/language-reference/index.md) -- [C# Programming Guide](../../../csharp/programming-guide/index.md) -- [C# Operators](../../../csharp/language-reference/operators/index.md) + +The division operator `/` divides its first operand by its second operand. All numeric types support the division operator. + +## Integer division + +For the operands of integer types, the result of the `/` operator is of an integer type and equals the quotient of the two operands rounded towards zero: + +[!code-csharp-interactive[integer division](~/samples/snippets/csharp/language-reference/operators/DivisionExamples.cs#Integer)] + +To obtain the quotient of the two operands as a floating-point number, use the `float`, `double`, or `decimal` type: + +[!code-csharp-interactive[integer as floating-point division](~/samples/snippets/csharp/language-reference/operators/DivisionExamples.cs#IntegerAsFloatingPoint)] + +## Floating-point division + +For the `float`, `double`, and `decimal` types, the result of the `/` operator is the quotient of the two operands: + +[!code-csharp-interactive[floating-point division](~/samples/snippets/csharp/language-reference/operators/DivisionExamples.cs#FloatingPoint)] + +If one of the operands is `decimal`, another operand can be neither `float` nor `double`, because neither `float` nor `double` is implicitly convertible to `decimal`. You must explicitly convert the `float` or `double` operand to the `decimal` type. For more information about implicit conversions between numeric types, see [Implicit numeric conversions table](../keywords/implicit-numeric-conversions-table.md). + +## Operator overloadability + +User-defined types can [overload](../keywords/operator.md) the `/` operator. When the `/` operator is overloaded, the [division assignment operator](division-assignment-operator.md) `/=` is also implicitly overloaded. + +## C# language specification + +For more information, see the [Division operator](~/_csharplang/spec/expressions.md#division-operator) section of the [C# language specification](../language-specification/index.md). + +## See also + +- [C# Reference](../index.md) +- [C# Programming Guide](../../programming-guide/index.md) +- [C# Operators](index.md) +- [% Operator](remainder-operator.md) diff --git a/docs/csharp/programming-guide/classes-and-structs/polymorphism.md b/docs/csharp/programming-guide/classes-and-structs/polymorphism.md index 0ef3a20a4aa78..2b015bf9c7358 100644 --- a/docs/csharp/programming-guide/classes-and-structs/polymorphism.md +++ b/docs/csharp/programming-guide/classes-and-structs/polymorphism.md @@ -91,8 +91,7 @@ Polymorphism is often referred to as the third pillar of object-oriented program ## See Also -- [C# Programming Guide](../../../csharp/programming-guide/index.md) -- [C# Programming Guide](../../../csharp/programming-guide/index.md) +- [C# Programming Guide](../../../csharp/programming-guide/index.md) - [Inheritance](../../../csharp/programming-guide/classes-and-structs/inheritance.md) - [Abstract and Sealed Classes and Class Members](../../../csharp/programming-guide/classes-and-structs/abstract-and-sealed-classes-and-class-members.md) - [Methods](../../../csharp/programming-guide/classes-and-structs/methods.md) diff --git a/docs/framework/wcf/fundamental-concepts.md b/docs/framework/wcf/fundamental-concepts.md index f7ccd91be7ea2..fa7bc2a6baf7c 100644 --- a/docs/framework/wcf/fundamental-concepts.md +++ b/docs/framework/wcf/fundamental-concepts.md @@ -49,7 +49,7 @@ This document provides a high-level view of the Windows Communication Foundation A construct that exposes one or more endpoints, with each endpoint exposing one or more service operations. endpoint - A construct at which messages are sent or received (or both). It comprises a location (an address) that defines where messages can be sent, a specification of the communication mechanism (a binding) that described how messages should be sent, and a definition for a set of messages that can be sent or received (or both) at that location (a service contract) that describes what message can be sent. + A construct at which messages are sent or received (or both). It comprises a location (an address) that defines where messages can be sent, a specification of the communication mechanism (a binding) that describes how messages should be sent, and a definition for a set of messages that can be sent or received (or both) at that location (a service contract) that describes what message can be sent. A WCF service is exposed to the world as a collection of endpoints. diff --git a/docs/fsharp/style-guide/formatting.md b/docs/fsharp/style-guide/formatting.md index f925409ee7da0..23ab9486276d3 100644 --- a/docs/fsharp/style-guide/formatting.md +++ b/docs/fsharp/style-guide/formatting.md @@ -337,16 +337,23 @@ type PostalAddress = } ``` -Placing the opening token on the same line and the closing token on a new line is also fine, but be aware that you need to use the [verbose syntax](../language-reference/verbose-syntax.md) to define members (the `with` keyword): +Placing the opening token on a new line and the closing token on a new line is preferrable if you are declaring interface implementations or members on the record: ```fsharp -// OK, but verbose syntax required -type PostalAddress = { - Address: string - City: string - Zip: string -} with +// Declaring additional members on PostalAddress +type PostalAddress = + { + Address: string + City: string + Zip: string + } with member x.ZipAndCity = sprintf "%s %s" x.Zip x.City + +type MyRecord = + { + SomeField : int + } + interface IMyInterface ``` ## Formatting records @@ -365,27 +372,51 @@ let rainbow = Lackeys = ["Zippy"; "George"; "Bungle"] } ``` -Placing the opening token on the same line and the closing token on a new line is also fine: +Placing the opening token on a new line, the contents tabbed over one scope, and the closing token on a new line is preferrable if you are: + +* Moving records around in code with different indentation scopes +* Piping them into a function ```fsharp -let rainbow = { - Boss1 = "Jeffrey" - Boss2 = "Jeffrey" - Boss3 = "Jeffrey" - Boss4 = "Jeffrey" - Boss5 = "Jeffrey" - Boss6 = "Jeffrey" - Boss7 = "Jeffrey" - Boss8 = "Jeffrey" - Lackeys = ["Zippy"; "George"; "Bungle"] -} +let rainbow = + { + Boss1 = "Jeffrey" + Boss2 = "Jeffrey" + Boss3 = "Jeffrey" + Boss4 = "Jeffrey" + Boss5 = "Jeffrey" + Boss6 = "Jeffrey" + Boss7 = "Jeffrey" + Boss8 = "Jeffrey" + Lackeys = ["Zippy"; "George"; "Bungle"] + } + +type MyRecord = + { + SomeField : int + } + interface IMyInterface + +let foo a = + a + |> Option.map (fun x -> + { + MyField = x + }) ``` The same rules apply for list and array elements. ## Formatting lists and arrays -Write `x :: l` with spaces around the `::` operator (`::` is an infix operator, hence surrounded by spaces) and `[1; 2; 3]` (`;` is a delimiter, hence followed by a space). +Write `x :: l` with spaces around the `::` operator (`::` is an infix operator, hence surrounded by spaces). + +List and arrays declared on a single line should have a space after the opening bracket and before the closing bracket: + +```fsharp +let xs = [ 1; 2; 3 ] +let ys = [| 1; 2; 3; |] +``` Always use at least one space between two distinct brace-like operators. For example, leave a space between a `[` and a `{`. @@ -408,19 +439,22 @@ Always use at least one space between two distinct brace-like operators. For exa Lists and arrays that split across multiple lines follow a similar rule as records do: ```fsharp -let pascalsTriangle = [| - [|1|] - [|1; 1|] - [|1; 2; 1|] - [|1; 3; 3; 1|] - [|1; 4; 6; 4; 1|] - [|1; 5; 10; 10; 5; 1|] - [|1; 6; 15; 20; 15; 6; 1|] - [|1; 7; 21; 35; 35; 21; 7; 1|] - [|1; 8; 28; 56; 70; 56; 28; 8; 1|] -|] +let pascalsTriangle = + [| + [|1|] + [|1; 1|] + [|1; 2; 1|] + [|1; 3; 3; 1|] + [|1; 4; 6; 4; 1|] + [|1; 5; 10; 10; 5; 1|] + [|1; 6; 15; 20; 15; 6; 1|] + [|1; 7; 21; 35; 35; 21; 7; 1|] + [|1; 8; 28; 56; 70; 56; 28; 8; 1|] + |] ``` +And as with records, declaring the opening and closing brackets on their own line will make moving code around and piping into functions easier. + ## Formatting if expressions Indentation of conditionals depends on the sizes of the expressions that make them up. If `cond`, `e1` and `e2` are short, simply write them on one line: diff --git a/docs/standard/datetime/working-with-calendars.md b/docs/standard/datetime/working-with-calendars.md index b615fc08eccfe..5a0604837a89b 100644 --- a/docs/standard/datetime/working-with-calendars.md +++ b/docs/standard/datetime/working-with-calendars.md @@ -131,6 +131,9 @@ However, there is one important exception. The default (uninitialized) value of Calendars typically divide dates into eras. However, the classes in .NET do not support every era defined by a calendar, and most of the classes support only a single era. Only the and classes support multiple eras. +> [!IMPORTANT] +> A new era in the and begins on May 1, 2019. This change affects all applications that use these calendars. See [Handling a new era in the Japanese calendar in .NET](https://blogs.msdn.microsoft.com/dotnet/2018/11/14/handling-a-new-era-in-the-japanese-calendar-in-net/) for more information and to determine whether your applications are affected. See [Prepare your application for the Japanese era change](~/windows/uwp/design/globalizing/japanese-era-change) for information on testing your applications on Windows to ensure their readiness for the era change. + ### Eras and era names In .NET, integers that represent the eras supported by a particular calendar implementation are stored in reverse order in the array. The current era is at index zero, and for classes that support multiple eras, each successive index reflects the previous era. The static property defines the index of the current era in the array; it is a constant whose value is always zero. Individual classes also include static fields that return the value of the current era. They are listed in the following table.