diff --git a/.openpublishing.redirection.json b/.openpublishing.redirection.json index 3ec4287ec8d07..06477deadeb01 100644 --- a/.openpublishing.redirection.json +++ b/.openpublishing.redirection.json @@ -601,6 +601,10 @@ "source_path": "docs/csharp/getting-started/with-visual-studio.md", "redirect_url": "/dotnet/core/tutorials/with-visual-studio" }, + { + "source_path": "docs/csharp/implicitly-typed-lambda-expressions.md", + "redirect_url": "/dotnet/csharp/programming-guide/statements-expressions-operators" + }, { "source_path": "docs/csharp/interactive-with-bash.md", "redirect_url": "/dotnet/csharp/index" @@ -1065,6 +1069,10 @@ "source_path": "docs/csharp/language-reference/operators/xor-operator.md", "redirect_url": "/dotnet/csharp/language-reference/operators/boolean-logical-operators#logical-exclusive-or-operator-" }, + { + "source_path": "docs/csharp/local-functions-vs-lambdas.md", + "redirect_url": "/dotnet/csharp/programming-guide/classes-and-structs/local-functions" + }, { "source_path": "docs/csharp/methods-lambda-expressions.md", "redirect_url": "/dotnet/csharp/programming-guide/statements-expressions-operators/lambda-expressions" @@ -3745,6 +3753,10 @@ "source_path": "docs/standard/serialization/add-element-for-xmlschemaimporterextensions.md", "redirect_url": "/dotnet/standard/serialization/add-element-for-schemaimporterextensions" }, + { + "source_path": "docs/standard/serialization/custom-serialization-order-with-xmlserializer.md", + "redirect_url": "/dotnet/standard/serialization/xml-and-soap-serialization" + }, { "source_path": "docs/standard/serialization/marshal-by-value.md", "redirect_url": "/dotnet/standard/serialization/serialization-concepts" @@ -3753,6 +3765,18 @@ "source_path": "docs/standard/serialization/persistent-storage.md", "redirect_url": "/dotnet/standard/serialization/serialization-concepts" }, + { + "source_path": "docs/standard/serialization/samples-binary.md", + "redirect_url": "/dotnet/standard/serialization/basic-serialization-technology-sample" + }, + { + "source_path": "docs/standard/serialization/samples-xml.md", + "redirect_url": "/dotnet/standard/serialization/xml-and-soap-serialization" + }, + { + "source_path": "docs/standard/serialization/schemaimporterextension-technology-sample.md", + "redirect_url": "/dotnet/standard/serialization/basic-serialization-technology-sample" + }, { "source_path": "docs/standard/serialization/serialization-how-to-topics.md", "redirect_url": "/dotnet/standard/serialization/how-to-serialize-an-object" @@ -3765,6 +3789,14 @@ "source_path": "docs/standard/serialization/serialization-tools.md", "redirect_url": "/dotnet/standard/serialization/xml-serializer-generator-tool-sgen-exe" }, + { + "source_path": "docs/standard/serialization/version-tolerant-serialization-technology-sample.md", + "redirect_url": "/dotnet/standard/serialization/basic-serialization-technology-sample" + }, + { + "source_path": "docs/standard/serialization/web-services-generics-serialization-technology-sample.md", + "redirect_url": "/dotnet/standard/serialization/basic-serialization-technology-sample" + }, { "source_path": "docs/standard/serialization/web-services-ixmlserializable-technology-sample.md", "redirect_url": "https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/h2byscsb(v=vs.100)" diff --git a/docs/csharp/implicitly-typed-lambda-expressions.md b/docs/csharp/implicitly-typed-lambda-expressions.md deleted file mode 100644 index 98f10d5bc774f..0000000000000 --- a/docs/csharp/implicitly-typed-lambda-expressions.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: Implicitly typed lambda expressions -description: Learn why you can't use an implicitly-typed variable declaration to declare a lambda expression. -ms.date: 06/20/2016 -ms.technology: csharp-advanced-concepts -ms.assetid: a3851da9-e018-4389-9922-233db7d0f841 ---- - -# Implicitly typed lambda expressions - -You can't use an implicitly typed variable declaration to declare a lambda expression. -It creates a circular logic problem for the compiler. The `var` declaration -tells the compiler to figure out the type of the variable from the type -of expression on the right hand side of the assignment operator. A lambda -expression does not have a compile time type, but is convertible to any -matching delegate or expression type. When you assign a lambda expression -to a variable of a delegate or expression type, you tell the compiler to -try and convert the lambda expression into an expression or delegate that -matches the signature of the 'assigned to' variable. The compiler must -try to make the thing on the right hand side of the assignment match -the type on the left hand side of the assignment. - -Both sides of the assignment can't be telling the compiler to look at the -object on the other side of the assignment operator and see if my type -matches. - -You can get even more details on why the C# language specifies that behavior -by reading [this article](https://download.microsoft.com/download/5/4/B/54B83DFE-D7AA-4155-9687-B0CF58FF65D7/type-inference.pdf) (PDF download). diff --git a/docs/csharp/local-functions-vs-lambdas.md b/docs/csharp/local-functions-vs-lambdas.md deleted file mode 100644 index 0a60fadf47d44..0000000000000 --- a/docs/csharp/local-functions-vs-lambdas.md +++ /dev/null @@ -1,110 +0,0 @@ ---- -title: Local functions vs. lambda expressions -description: Learn why local functions might be a better choice than lambda expressions. -ms.date: 06/27/2016 -ms.technology: csharp-advanced-concepts -ms.assetid: 368d1752-3659-489a-97b4-f15d87e49ae3 ---- -# Local functions compared to lambda expressions - -At first glance, [local functions](programming-guide/classes-and-structs/local-functions.md) and [lambda expressions](./programming-guide/statements-expressions-operators/lambda-expressions.md) are very similar. In many cases, the choice between using -lambda expressions and local functions is a matter of style and personal -preference. However, there are real differences in where you can use one or -the other that you should be aware of. - -Let's examine the differences between the local function and lambda expression -implementations of the factorial algorithm. First the version using a local function: - -[!code-csharp[LocalFunctionFactorial](../../samples/snippets/csharp/new-in-7/MathUtilities.cs#37_LocalFunctionFactorial "Recursive factorial using local function")] - -Contrast that implementation with a version that uses lambda expressions: - -[!code-csharp[26_LambdaFactorial](../../samples/snippets/csharp/new-in-7/MathUtilities.cs#38_LambdaFactorial "Recursive factorial using lambda expressions")] - -The local functions have names. The lambda expressions are anonymous methods -that are assigned to variables that are `Func` or `Action` types. When you -declare a local function, the argument types and return type are part of the -function declaration. Instead of being part of the body of the lambda expression, the argument types and return type are part of the lambda -expression's variable type declaration. Those two differences may -result in clearer code. - -Local functions have different rules for definite assignment -than lambda expressions. A local function declaration can be referenced -from any code location where it is in scope. A lambda expression must be -assigned to a delegate variable before it can be accessed (or called through the delegate -referencing the lambda expression.) Notice that the version using the -lambda expression must declare and initialize the lambda expression, -`nthFactorial` before defining it. Not doing so results in a compile -time error for referencing `nthFactorial` before assigning it. -These differences mean that recursive algorithms are easier to create -using local functions. You can declare and define a local function that -calls itself. Lambda expressions must be declared, and assigned a default -value before they can be re-assigned to a body that references the same -lambda expression. - -Definite assignment rules also affect any variables that are captured -by the local function or lambda expression. Both local functions and -lambda expression rules demand that any captured variables are definitely -assigned at the point when the local function or lambda expression is -converted to a delegate. The difference is that lambda expressions are converted -to delegates when they are declared. Local functions are converted to delegates -only when used as a delegate. If you declare a local function and only -reference it by calling it like a method, it will not be converted to -a delegate. That rule enables you to declare -a local function at any convenient location in its enclosing scope. It's common -to declare local functions at the end of the parent method, after any return -statements. - -Third, the compiler can perform static analysis that enables local functions to -definitely assign captured variables in the enclosing scope. Consider this example: - -```csharp -int M() -{ - int y; - LocalFunction(); - return y; - - void LocalFunction() => y = 0; -} -``` - -The compiler can determine that `LocalFunction` definitely assigns `y` when called. Because `LocalFunction` is called before the `return` statement, `y` is definitely -assigned at the `return` statement. - -The analysis that enables the example analysis enables the fourth difference. -Depending on their use, local functions can avoid heap allocations that -are always necessary for lambda expressions. If a local function is never -converted to a delegate, and none of the variables captured by the local function is captured by other lambdas or local functions that are converted to delegates, the compiler can avoid heap allocations. - -Consider this async example: - -[!code-csharp[TaskLambdaExample](../../samples/snippets/csharp/new-in-7/AsyncWork.cs#36_TaskLambdaExample "Task returning method with lambda expression")] - -The closure for this lambda expression contains the `address`, -`index` and `name` variables. In the case of local functions, the object -that implements the closure may be a `struct` type. That struct type would -be passed by reference to the local function. This difference in -implementation would save on -an allocation. - -The instantiation necessary for lambda expressions means extra memory -allocations, which may be a performance factor in time-critical code paths. -Local functions do not incur this overhead. In the example above, the local -functions version has 2 fewer allocations than the lambda expression version. - -> [!NOTE] -> The local function equivalent of this method also uses a class for the closure. Whether the closure for a local function is implemented as a `class` or a `struct` is an implementation detail. A local function may use a `struct` whereas a lambda will always use a `class`. - -[!code-csharp[TaskLocalFunctionExample](../../samples/snippets/csharp/new-in-7/AsyncWork.cs#TaskExample "Task returning method with local function")] - -One final advantage not demonstrated in this sample is that local -functions can be implemented as iterators, using the `yield return` -syntax to produce a sequence of values. The `yield return` statement -is not allowed in lambda expressions. - -While local functions may seem redundant to lambda expressions, -they actually serve different purposes and have different uses. -Local functions are more efficient for the case when you want -to write a function that is called only from the context of -another method. diff --git a/docs/csharp/programming-guide/classes-and-structs/local-functions.md b/docs/csharp/programming-guide/classes-and-structs/local-functions.md index 384fecc76a0dd..d4d680a381f0c 100644 --- a/docs/csharp/programming-guide/classes-and-structs/local-functions.md +++ b/docs/csharp/programming-guide/classes-and-structs/local-functions.md @@ -20,7 +20,7 @@ Starting with C# 7.0, C# supports *local functions*. Local functions are private However, local functions can't be declared inside an expression-bodied member. > [!NOTE] -> In some cases, you can use a lambda expression to implement functionality also supported by a local function. For a comparison, see [Local functions compared to Lambda expressions](../../local-functions-vs-lambdas.md). +> In some cases, you can use a lambda expression to implement functionality also supported by a local function. For a comparison, see [Local functions vs. lambda expressions](#local-functions-vs-lambda-expressions). Local functions make the intent of your code clear. Anyone reading your code can see that the method is not callable except by the containing method. For team projects, they also make it impossible for another developer to mistakenly call the method directly from elsewhere in the class or struct. @@ -69,6 +69,59 @@ As we did with the method iterator, we can refactor the code from this example t [!code-csharp[LocalFunctionAsync](~/samples/snippets/csharp/programming-guide/classes-and-structs/local-functions-async2.cs)] +## Local functions vs. lambda expressions + +At first glance, local functions and [lambda expressions](../statements-expressions-operators/lambda-expressions.md) are very similar. In many cases, the choice between using lambda expressions and local functions is a matter of style and personal preference. However, there are real differences in where you can use one or the other that you should be aware of. + +Let's examine the differences between the local function and lambda expression implementations of the factorial algorithm. First the version using a local function: + +[!code-csharp[LocalFunctionFactorial](../../../../samples/snippets/csharp/new-in-7/MathUtilities.cs#37_LocalFunctionFactorial "Recursive factorial using local function")] + +Contrast that implementation with a version that uses lambda expressions: + +[!code-csharp[26_LambdaFactorial](../../../../samples/snippets/csharp/new-in-7/MathUtilities.cs#38_LambdaFactorial "Recursive factorial using lambda expressions")] + +The local functions have names. The lambda expressions are anonymous methods that are assigned to variables that are `Func` or `Action` types. When you +declare a local function, the argument types and return type are part of the function declaration. Instead of being part of the body of the lambda expression, the argument types and return type are part of the lambda expression's variable type declaration. Those two differences may result in clearer code. + +Local functions have different rules for definite assignment than lambda expressions. A local function declaration can be referenced from any code location where it is in scope. A lambda expression must be assigned to a delegate variable before it can be accessed (or called through the delegate referencing the lambda expression). Notice that the version using the lambda expression must declare and initialize the lambda expression `nthFactorial` before defining it. Not doing so results in a compile time error for referencing `nthFactorial` before assigning it. These differences mean that recursive algorithms are easier to create using local functions. You can declare and define a local function that calls itself. Lambda expressions must be declared, and assigned a default value before they can be re-assigned to a body that references the same lambda expression. + +Definite assignment rules also affect any variables that are captured by the local function or lambda expression. Both local functions and lambda expression rules demand that any captured variables are definitely assigned at the point when the local function or lambda expression is converted to a delegate. The difference is that lambda expressions are converted to delegates when they are declared. Local functions are converted to delegates only when used as a delegate. If you declare a local function and only reference it by calling it like a method, it will not be converted to a delegate. That rule enables you to declare a local function at any convenient location in its enclosing scope. It's common to declare local functions at the end of the parent method, after any return statements. + +Third, the compiler can perform static analysis that enables local functions to definitely assign captured variables in the enclosing scope. Consider this example: + +```csharp +int M() +{ + int y; + LocalFunction(); + return y; + + void LocalFunction() => y = 0; +} +``` + +The compiler can determine that `LocalFunction` definitely assigns `y` when called. Because `LocalFunction` is called before the `return` statement, `y` is definitely assigned at the `return` statement. + +The analysis that enables the example analysis enables the fourth difference. Depending on their use, local functions can avoid heap allocations that are always necessary for lambda expressions. If a local function is never converted to a delegate, and none of the variables captured by the local function is captured by other lambdas or local functions that are converted to delegates, the compiler can avoid heap allocations. + +Consider this async example: + +[!code-csharp[TaskLambdaExample](../../../../samples/snippets/csharp/new-in-7/AsyncWork.cs#36_TaskLambdaExample "Task returning method with lambda expression")] + +The closure for this lambda expression contains the `address`, `index` and `name` variables. In the case of local functions, the object that implements the closure may be a `struct` type. That struct type would be passed by reference to the local function. This difference in implementation would save on an allocation. + +The instantiation necessary for lambda expressions means extra memory allocations, which may be a performance factor in time-critical code paths. Local functions do not incur this overhead. In the example above, the local functions version has 2 fewer allocations than the lambda expression version. + +> [!NOTE] +> The local function equivalent of this method also uses a class for the closure. Whether the closure for a local function is implemented as a `class` or a `struct` is an implementation detail. A local function may use a `struct` whereas a lambda will always use a `class`. + +[!code-csharp[TaskLocalFunctionExample](../../../../samples/snippets/csharp/new-in-7/AsyncWork.cs#TaskExample "Task returning method with local function")] + +One final advantage not demonstrated in this sample is that local functions can be implemented as iterators, using the `yield return` syntax to produce a sequence of values. The `yield return` statement is not allowed in lambda expressions. + +While local functions may seem redundant to lambda expressions, they actually serve different purposes and have different uses. Local functions are more efficient for the case when you want to write a function that is called only from the context of another method. + ## See also - [Methods](methods.md) diff --git a/docs/csharp/programming-guide/statements-expressions-operators/lambda-expressions.md b/docs/csharp/programming-guide/statements-expressions-operators/lambda-expressions.md index 4454fd8a89dce..50f0d7313ab05 100644 --- a/docs/csharp/programming-guide/statements-expressions-operators/lambda-expressions.md +++ b/docs/csharp/programming-guide/statements-expressions-operators/lambda-expressions.md @@ -224,7 +224,7 @@ For more information, see the [Anonymous function expressions](~/_csharplang/spe - [C# Programming Guide](../index.md) - [LINQ (Language-Integrated Query)](../concepts/linq/index.md) - [Expression Trees](../concepts/expression-trees/index.md) -- [Local functions compared to lambda expressions](../../local-functions-vs-lambdas.md) +- [Local functions vs. lambda expressions](../classes-and-structs/local-functions.md#local-functions-vs-lambda-expressions) - [Implicitly typed lambda expressions](../../implicitly-typed-lambda-expressions.md) - [Visual Studio 2008 C# Samples (see LINQ Sample Queries files and XQuery program)](https://code.msdn.microsoft.com/Visual-Studio-2008-C-d295cdba) - [Recursive lambda expressions](https://docs.microsoft.com/archive/blogs/madst/recursive-lambda-expressions) diff --git a/docs/csharp/toc.yml b/docs/csharp/toc.yml index e3d42870998d4..3d65b05ca6a01 100644 --- a/docs/csharp/toc.yml +++ b/docs/csharp/toc.yml @@ -1219,6 +1219,8 @@ href: programming-guide/xmldoc/exception.md - name: href: programming-guide/xmldoc/include.md + - name: + href: programming-guide/xmldoc/inheritdoc.md - name: href: programming-guide/xmldoc/list.md - name: diff --git a/docs/csharp/whats-new/csharp-7.md b/docs/csharp/whats-new/csharp-7.md index 5fa27638e6762..6a612e64b1c4d 100644 --- a/docs/csharp/whats-new/csharp-7.md +++ b/docs/csharp/whats-new/csharp-7.md @@ -261,8 +261,7 @@ work begins: [!code-csharp[TaskExample](~/samples/snippets/csharp/new-in-7/AsyncWork.cs#TaskExample "Task returning method with local function")] > [!NOTE] -> Some of the designs that are supported by local functions -> could also be accomplished using *lambda expressions*. For more information, see [Local functions vs. lambda expressions](../local-functions-vs-lambdas.md). +> Some of the designs that are supported by local functions can also be accomplished using *lambda expressions*. For more information, see [Local functions vs. lambda expressions](../programming-guide/classes-and-structs/local-functions.md#local-functions-vs-lambda-expressions). ## More expression-bodied members diff --git a/docs/standard/serialization/custom-serialization-order-with-xmlserializer.md b/docs/standard/serialization/custom-serialization-order-with-xmlserializer.md deleted file mode 100644 index f6601a92035c8..0000000000000 --- a/docs/standard/serialization/custom-serialization-order-with-xmlserializer.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -title: "Custom Serialization Order With XmlSerializer" -ms.date: "03/30/2017" -ms.assetid: 975abd20-2a1d-42db-aed3-e898025ccce7 ---- -# Custom Serialization Order With XmlSerializer -[Download Sample](https://download.microsoft.com/download/4/7/B/47B2164C-E780-4B10-8DE4-2CB5B886E0A6/Technologies/Serialization/Xml%20Serialization/CustomOrder.zip.exe) - - This sample shows how to control the order of serialized and deserialized elements for XML serialization. - - Review comments in the source code and build.proj files for more information on serialization. - -### To build the sample using the Command Prompt - -1. Open the Command Prompt window and navigate to one of the language-specific subdirectories for the sample. - -2. Type **msbuild CustomOrder.sln** at the command line. - -### To build the sample using Visual Studio - -1. Open File Explorer and navigate to one of the language-specific subdirectories for the sample. - -2. Double-click the icon for the CustomOrder.sln to open the file in Visual Studio. - -3. In the **Build** menu, select **Build Solution**. - -4. The sample application is built in the default \bin or \bin\Debug subdirectory. - -## See also - -- [Basic Serialization](../../../docs/standard/serialization/basic-serialization.md) -- [Binary Serialization](../../../docs/standard/serialization/binary-serialization.md) -- [Controlling XML Serialization Using Attributes](../../../docs/standard/serialization/controlling-xml-serialization-using-attributes.md) -- [Introducing XML Serialization](../../../docs/standard/serialization/introducing-xml-serialization.md) -- [Serialization](../../../docs/standard/serialization/index.md) -- [XML and SOAP Serialization](../../../docs/standard/serialization/xml-and-soap-serialization.md) diff --git a/docs/standard/serialization/samples-binary.md b/docs/standard/serialization/samples-binary.md deleted file mode 100644 index 75fc45a6a1a03..0000000000000 --- a/docs/standard/serialization/samples-binary.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -title: "Binary serialization samples for .NET" -ms.date: "03/30/2017" ---- -# Binary Serialization Samples for .NET - -* [Basic binary serialization technology sample](../../../docs/standard/serialization/basic-serialization-technology-sample.md) - Demonstrates how to serialize an object graph in memory to a stream. - -* [Version tolerant serialization technology sample](../../../docs/standard/serialization/version-tolerant-serialization-technology-sample.md) - Demonstrates the version tolerance features of .NET Serialization. diff --git a/docs/standard/serialization/samples-xml.md b/docs/standard/serialization/samples-xml.md deleted file mode 100644 index b52d43029ec7f..0000000000000 --- a/docs/standard/serialization/samples-xml.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -title: "XML serialization samples for .NET" -ms.date: "03/30/2017" ---- -# XML serialization samples for .NET - -* [Basic XML serialization technology sample](../../../docs/standard/serialization/basic-serialization-technology-sample.md) - Demonstrates how to serialize an object graph in memory to a stream. - -* [Web services generics serialization technology sample](../../../docs/standard/serialization/web-services-generics-serialization-technology-sample.md) - Shows how to use and control the serialization of generics in ASP.NET Web Services. - -* [SchemaImporterExtension technology sample](../../../docs/standard/serialization/schemaimporterextension-technology-sample.md) - Demonstrates a custom . - -* [Custom serialization order with XmlSerializer](../../../docs/standard/serialization/custom-serialization-order-with-xmlserializer.md) - Shows how to control the order of serialized and deserialized elements for XML serialization. diff --git a/docs/standard/serialization/schemaimporterextension-technology-sample.md b/docs/standard/serialization/schemaimporterextension-technology-sample.md deleted file mode 100644 index 98801fb342d86..0000000000000 --- a/docs/standard/serialization/schemaimporterextension-technology-sample.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -title: "SchemaImporterExtension Technology Sample" -ms.date: "03/30/2017" -ms.assetid: 3f5eb78f-0ef6-433a-b095-3a63b1ce0bc9 ---- -# SchemaImporterExtension Technology Sample -[Download Sample](https://download.microsoft.com/download/4/7/B/47B2164C-E780-4B10-8DE4-2CB5B886E0A6/Technologies/Serialization/Xml%20Serialization/SchemaImporterExtension.zip.exe) - - This sample demonstrates a custom that allows fine control over code generation when an XML schema is imported. The application shows how to build, register and invoke this extension. - -### To build the sample using the command prompt - -1. Open a Command Prompt window and navigate to one of the language-specific subdirectories for the sample. - -2. Type **msbuild.exe OrderSchemaImporterExtension.sln** at the command line. - -### To build the sample using Visual Studio - -1. Open File Explorer and navigate to one of the language-specific subdirectories for the sample. - -2. Double-click the icon for OrderSchemaImporterExtension.sln to open the file in Visual Studio. - -3. On the **Build** menu, click **Build Solution**. - - The application will be built in the default \bin or \bin\Debug directory. - -### To run the sample - -1. Navigate to the directory containing the new executable, using the command prompt. - -2. Type **[exe name]** at the command line. - -## Remarks - For more information about sample binary creation and registration steps, see the comments in the source code and build.proj files. - -## See also - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- diff --git a/docs/standard/serialization/version-tolerant-serialization-technology-sample.md b/docs/standard/serialization/version-tolerant-serialization-technology-sample.md deleted file mode 100644 index ef35aac08d6be..0000000000000 --- a/docs/standard/serialization/version-tolerant-serialization-technology-sample.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -title: "Version Tolerant Serialization Technology Sample" -ms.date: "03/30/2017" -ms.assetid: 2a183664-bfbf-4ff0-96f6-c836284ea916 ---- -# Version Tolerant Serialization Technology Sample -[Download Sample](https://download.microsoft.com/download/4/7/B/47B2164C-E780-4B10-8DE4-2CB5B886E0A6/Technologies/Serialization/Runtime%20Serialization/VTS.zip.exe) - - This sample demonstrates the version tolerance features of .NET Serialization. The sample builds applications that use different versions of a to serialize and deserialize data. Despite the presence of different type versions, the applications communicate seamlessly. For more information, see [Version Tolerant Serialization](../../../docs/standard/serialization/version-tolerant-serialization.md). - -### To build the sample using the command prompt - -1. Open a Command Prompt window and navigate to one of the language-specific subdirectories (under V1 Application or V2 Application) for the sample. - -2. Type **msbuild.exe \ application.sln** at the command line (where \ is either v1 or v2). - -### To build the sample using Visual Studio - -1. Open File Explorer and navigate to one of the language-specific subdirectories for the sample. - -2. Navigate to the V1 Application subdirectory of the directory you selected in the previous step. - -3. Double-click the icon for V1 Application.sln to open the file in Visual Studio. - -4. On the **Build** menu, click **Build Solution**. - -5. Navigate to the V2 Application subdirectory and repeat the two previous steps to build the V2 Application. - - The applications will be built in the default \bin or \bin\Debug subdirectories of their respective project directories. - -### To run the sample - -1. In the Command Prompt window, navigate to the language-specific subdirectory that you selected when you built the sample applications. - -2. Type **runme.cmd** at the command line to run both applications at once. - - Alternatively, navigate to the directories that contain the new executables and run them sequentially. - -> [!NOTE] -> The sample builds console applications. You must launch and run them in a Command Prompt window to view their output. - -## See also - -- -- diff --git a/docs/standard/serialization/web-services-generics-serialization-technology-sample.md b/docs/standard/serialization/web-services-generics-serialization-technology-sample.md deleted file mode 100644 index fb24ef72a4102..0000000000000 --- a/docs/standard/serialization/web-services-generics-serialization-technology-sample.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -title: "Web Services Generics Serialization Technology Sample" -ms.date: "03/30/2017" -ms.assetid: cdc15ea4-f678-4729-8ebe-188ae720bef7 ---- -# Web Services Generics Serialization Technology Sample -[Download Sample](https://download.microsoft.com/download/4/7/B/47B2164C-E780-4B10-8DE4-2CB5B886E0A6/Technologies/Serialization/Xml%20Serialization/GenericsSerialization.zip.exe) - - This sample shows how to use and control the serialization of generics in ASP.NET Web Services. - -### To build the sample using Visual Studio - -1. Open Visual Studio and select **New Web Site** from the **File** menu. - -2. In the **New Web Site** dialog, select from the left pane your desired programming language, then from the right pane, select **ASP.NET Web Service**. - -3. Click **Browse** and navigate to the \CS\GenericsService subdirectory. - -4. Select Service.asmx to open the file in Visual Studio. - -5. On the **Build** menu, click **Build Solution**. - -> [!NOTE] -> The first five steps in this list are optional. The .NET Framework runtime will automatically generate the Web service the first time the service is requested. - -> [!NOTE] -> The following steps are required to build the sample. - -1. Open File Explorer and navigate to the \CS subdirectory. - -2. Right-click the icon for the GenericsService subdirectory, and select **Sharing and Security**. - -3. In the **Web Sharing** tab, select **Share this Folder**. - -> [!IMPORTANT] -> Take note of the virtual directory name that is listed in the **Aliases** pane, because you will need it to run the sample. - -### To build the sample using Internet Information Services - -1. Open the **Internet Information Services** management snap-in and expand **Web Sites**. - -2. Left-click **Default Web Site**, select **New**, and then select **Virtual Directory?** to create the **Virtual Directory Creation Wizard**. - -3. Click **Next**, enter the public alias for your virtual directory, and click **Next**. - -4. Enter the path to the directory where you saved the sample (normally the \CS\GenericsService subdirectory) and click **Next**. Click **Next** to finish the wizard. - -> [!IMPORTANT] -> Take note of the virtual directory name that is listed in the **Alias** pane, because you will need it to run the sample. - -### To run the sample - -1. Open a browser window and select its address bar. - -2. Type `http://localhost/[virtual directory]/Service.asmx`, where `[virtual directory]` represents the virtual directory you created when you built the sample. - -## Remarks - The sample displays a default ASP.NET page that contains links to the definition of the Web Service. You can customize the display in addition to modifying the source code for the Web service. For more information, see [Building XML Web Service Clients](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/w3h45ebk(v=vs.100)). - -## See also - -- -- -- -- [Serialization](../../../docs/standard/serialization/index.md) -- [XML Web Services Created Using ASP.NET and XML Web Service Clients](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/7bkzywba(v=vs.100)) diff --git a/docs/standard/toc.yml b/docs/standard/toc.yml index acf8c72bf6aa1..62eba74585e06 100644 --- a/docs/standard/toc.yml +++ b/docs/standard/toc.yml @@ -748,8 +748,8 @@ href: serialization/how-to-chunk-serialized-data.md - name: "How to: Determine if a .NET Standard object is serializable" href: serialization/how-to-determine-if-netstandard-object-is-serializable.md - - name: Samples - href: serialization/samples-binary.md + - name: Sample + href: serialization/basic-serialization-technology-sample.md - name: XML and SOAP serialization items: - name: Overview @@ -804,8 +804,6 @@ href: serialization/xml-serializer-generator-tool-sgen-exe.md - name: XML Schema Definition tool (Xsd.exe) href: serialization/xml-schema-definition-tool-xsd-exe.md - - name: Samples - href: serialization/samples-xml.md - name: Develop for multiple platforms items: - name: Overview