diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml
index c0bfe5481d0e3..ba43ab3c0da5a 100644
--- a/.github/workflows/scorecards.yml
+++ b/.github/workflows/scorecards.yml
@@ -71,6 +71,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
- uses: github/codeql-action/upload-sarif@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3.28.11
+ uses: github/codeql-action/upload-sarif@1b549b9259bda1cb5ddde3b41741a82a2d15a841 # v3.28.13
with:
sarif_file: results.sarif
diff --git a/docs/ai/semantic-kernel-dotnet-overview.md b/docs/ai/semantic-kernel-dotnet-overview.md
index f2ee3e0f43b61..94eff8d840040 100644
--- a/docs/ai/semantic-kernel-dotnet-overview.md
+++ b/docs/ai/semantic-kernel-dotnet-overview.md
@@ -202,9 +202,9 @@ string memoryCollectionName = "SummarizedAzureDocs";
foreach (var fact in facts) {
await memoryBuilder.SaveReferenceAsync(
collection: memoryCollectionName,
- description: fact.Key.Split(";")[1].Trim(),
+ description: fact.Key.Split(";")[0].Trim(),
text: fact.Value,
- externalId: fact.Key.Split(";")[2].Trim(),
+ externalId: fact.Key.Split(";")[1].Trim(),
externalSourceName: "Azure Documentation"
);
}
diff --git a/docs/azure/sdk/snippets/aspnetcore-guidance/BlazorSample/BlazorSample.csproj b/docs/azure/sdk/snippets/aspnetcore-guidance/BlazorSample/BlazorSample.csproj
index 2621b90875ee8..6bf563e3648f6 100644
--- a/docs/azure/sdk/snippets/aspnetcore-guidance/BlazorSample/BlazorSample.csproj
+++ b/docs/azure/sdk/snippets/aspnetcore-guidance/BlazorSample/BlazorSample.csproj
@@ -10,7 +10,7 @@
-
+
diff --git a/docs/azure/sdk/snippets/pagination/pagination.csproj b/docs/azure/sdk/snippets/pagination/pagination.csproj
index bd8df00a151a7..e773d5cb70189 100644
--- a/docs/azure/sdk/snippets/pagination/pagination.csproj
+++ b/docs/azure/sdk/snippets/pagination/pagination.csproj
@@ -10,7 +10,7 @@
-
+
diff --git a/docs/core/diagnostics/lldb-linux.md b/docs/core/diagnostics/lldb-linux.md
index a7d7e73aca8a6..196d040d739ba 100644
--- a/docs/core/diagnostics/lldb-linux.md
+++ b/docs/core/diagnostics/lldb-linux.md
@@ -49,7 +49,7 @@ To install the LLDB packages:
```console
apk update
- apk add lldb
+ apk add lldb py3-lldb
```
To launch LLDB:
diff --git a/docs/core/tools/dotnet-test.md b/docs/core/tools/dotnet-test.md
index ab84bb29678cb..00360cea44371 100644
--- a/docs/core/tools/dotnet-test.md
+++ b/docs/core/tools/dotnet-test.md
@@ -25,7 +25,7 @@ Some examples of the `dotnet.config` file:
name = "VSTest"
```
-## VSTest and Microsoft Testing Platform (MTP)
+## VSTest and Microsoft.Testing.Platform (MTP)
### [dotnet test with VSTest](#tab/dotnet-test-with-vstest)
@@ -441,7 +441,7 @@ dotnet test -h|--help
With Microsoft Testing Platform, `dotnet test` operates faster than with VSTest. The test-related arguments are no longer fixed, as they are tied to the registered extensions in the test project(s). Moreover, MTP supports a globbing filter when running tests. For more information, see [Microsoft.Testing.Platform](../testing/microsoft-testing-platform-intro.md).
> [!WARNING]
-> `dotnet test` doesn't run in environments that have test projects using both VSTest and Microsoft Testing Platform in the same solution, as the two platforms are mutually incompatible.
+> When Microsoft.Testing.Platform is opted in via `dotnet.config`, `dotnet test` expects all test projects to use Microsoft.Testing.Platform. It is an error if any of the test projects use VSTest.
#### Implicit restore
@@ -449,6 +449,10 @@ With Microsoft Testing Platform, `dotnet test` operates faster than with VSTest.
#### Options
+> [!NOTE]
+> You can use only one of the following options at a time: `--project`, `--solution`, `--directory`, or `--test-modules`. These options can't be combined.
+> In addition, when using `--test-modules`, you can't specify `--arch`, `--configuration`, `--framework`, `--os`, or `--runtime`. These options are not relevant for an already-built module.
+
- **`--project `**
Specifies the path to the test project.
@@ -461,9 +465,6 @@ With Microsoft Testing Platform, `dotnet test` operates faster than with VSTest.
Specifies the path to a directory that contains a project or a solution.
-> [!NOTE]
-> You can use only one of the following options at a time: `--project`, `--solution`, or `--directory`. These options can't be combined.
-
- **`--test-modules `**
Filters test modules using file globbing in .NET. Only tests belonging to those test modules will run. For more information and examples on how to use file globbing in .NET, see [File globbing](../../../docs/core/extensions/file-globbing.md).
@@ -533,14 +534,17 @@ With Microsoft Testing Platform, `dotnet test` operates faster than with VSTest.
- **`args`**
- Specifies extra arguments to pass to the test application(s). Use a space to separate multiple arguments. For more information and examples on what to pass, see [Microsoft Testing Platform](../../../docs/core/testing/microsoft-testing-platform-intro.md) and [Microsoft.Testing.Platform extensions](../../../docs/core/testing/microsoft-testing-platform-extensions.md).
+ Specifies extra arguments to pass to the test application(s). Use a space to separate multiple arguments. For more information and examples on what to pass, see [Microsoft.Testing.Platform overview](../../../docs/core/testing/microsoft-testing-platform-intro.md) and [Microsoft.Testing.Platform extensions](../../../docs/core/testing/microsoft-testing-platform-extensions.md).
+
+ > [!TIP]
+ > To specify extra arguments for specific projects, use the `TestingPlatformCommandLineArguments` MSBuild property.
> [!NOTE]
> To enable trace logging to a file, use the environment variable `DOTNET_CLI_TEST_TRACEFILE` to provide the path to the trace file.
#### Examples
-- Run the tests in the project in the current directory:
+- Run the tests in the project or solution in the current directory:
```dotnetcli
dotnet test
@@ -558,7 +562,7 @@ With Microsoft Testing Platform, `dotnet test` operates faster than with VSTest.
dotnet test --solution ./TestProjects/TestProjects.sln
```
-- Run the tests in the `TestProjects` directory:
+- Run the tests in a solution or project that can be found in the `TestProjects` directory:
```dotnetcli
dotnet test --directory ./TestProjects
diff --git a/docs/csharp/advanced-topics/expression-trees/snippets/InterpretExpressions.cs b/docs/csharp/advanced-topics/expression-trees/snippets/InterpretExpressions.cs
index a9e39623a98e7..2f7811cd47e59 100644
--- a/docs/csharp/advanced-topics/expression-trees/snippets/InterpretExpressions.cs
+++ b/docs/csharp/advanced-topics/expression-trees/snippets/InterpretExpressions.cs
@@ -1,4 +1,4 @@
-using System.Linq.Expressions;
+using System.Linq.Expressions;
public static class InterpretExpressions
{
public static void ParseExpression()
@@ -16,8 +16,7 @@ public static void ParseExpression()
ParameterExpression left = (ParameterExpression)operation.Left;
ConstantExpression right = (ConstantExpression)operation.Right;
- Console.WriteLine("Decomposed expression: {0} => {1} {2} {3}",
- param.Name, left.Name, operation.NodeType, right.Value);
+ Console.WriteLine($"Decomposed expression: {param.Name} => {left.Name} {operation.NodeType} {right.Value}");
// This code produces the following output:
diff --git a/docs/csharp/advanced-topics/reflection-and-attributes/snippets/conceptual/Program.cs b/docs/csharp/advanced-topics/reflection-and-attributes/snippets/conceptual/Program.cs
index dc1df248ecb26..ec91f5c3fb994 100644
--- a/docs/csharp/advanced-topics/reflection-and-attributes/snippets/conceptual/Program.cs
+++ b/docs/csharp/advanced-topics/reflection-and-attributes/snippets/conceptual/Program.cs
@@ -1,4 +1,4 @@
-// See https://aka.ms/new-console-template for more information
+// See https://aka.ms/new-console-template for more information
using System.Reflection;
@@ -35,10 +35,10 @@ from method in type.GetMethods()
foreach (var groupOfMethods in pubTypesQuery)
{
- Console.WriteLine("Type: {0}", groupOfMethods.Key);
+ Console.WriteLine($"Type: {groupOfMethods.Key}");
foreach (var method in groupOfMethods)
{
- Console.WriteLine(" {0}", method);
+ Console.WriteLine($" {method}");
}
}
//
diff --git a/docs/csharp/asynchronous-programming/snippets/async-scenarios/Program.cs b/docs/csharp/asynchronous-programming/snippets/async-scenarios/Program.cs
index 7b6c61554fc8b..b386d1ddad6a9 100644
--- a/docs/csharp/asynchronous-programming/snippets/async-scenarios/Program.cs
+++ b/docs/csharp/asynchronous-programming/snippets/async-scenarios/Program.cs
@@ -1,4 +1,4 @@
-using System.Text.RegularExpressions;
+using System.Text.RegularExpressions;
using System.Windows;
using Microsoft.AspNetCore.Mvc;
@@ -111,7 +111,7 @@ private static void Download(string URL)
private static void DoSomethingWithData(object stringData)
{
- Console.WriteLine("Displaying data: ", stringData);
+ Console.WriteLine($"Displaying data: {stringData}");
}
//
diff --git a/docs/csharp/fundamentals/coding-style/snippets/coding-conventions/program.cs b/docs/csharp/fundamentals/coding-style/snippets/coding-conventions/program.cs
index 10611e00813fb..18dbb7db40d2f 100644
--- a/docs/csharp/fundamentals/coding-style/snippets/coding-conventions/program.cs
+++ b/docs/csharp/fundamentals/coding-style/snippets/coding-conventions/program.cs
@@ -1,4 +1,4 @@
-using System.Text;
+using System.Text;
namespace Coding_Conventions_Examples
{
@@ -32,7 +32,7 @@ public static void DelegateExamples()
public static void DelMethod(string str)
{
- Console.WriteLine("DelMethod argument: {0}", str);
+ Console.WriteLine($"DelMethod argument: {str}");
}
//
@@ -174,7 +174,7 @@ static void Main(string[] args)
if ((divisor != 0) && (dividend / divisor) is var result)
{
- Console.WriteLine("Quotient: {0}", result);
+ Console.WriteLine($"Quotient: {result}");
}
else
{
diff --git a/docs/csharp/fundamentals/exceptions/snippets/exceptions/ExceptionTest.cs b/docs/csharp/fundamentals/exceptions/snippets/exceptions/ExceptionTest.cs
index 0a7d35889912c..f254485e186a3 100644
--- a/docs/csharp/fundamentals/exceptions/snippets/exceptions/ExceptionTest.cs
+++ b/docs/csharp/fundamentals/exceptions/snippets/exceptions/ExceptionTest.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
namespace Exceptions
{
@@ -22,7 +22,7 @@ public static void Main()
try
{
result = SafeDivision(a, b);
- Console.WriteLine("{0} divided by {1} = {2}", a, b, result);
+ Console.WriteLine($"{a} divided by {b} = {result}");
}
catch (DivideByZeroException)
{
diff --git a/docs/csharp/fundamentals/object-oriented/snippets/objects/Application.cs b/docs/csharp/fundamentals/object-oriented/snippets/objects/Application.cs
index be3baf4e91dcb..35382d189fc94 100644
--- a/docs/csharp/fundamentals/object-oriented/snippets/objects/Application.cs
+++ b/docs/csharp/fundamentals/object-oriented/snippets/objects/Application.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
namespace Example
{
@@ -20,7 +20,7 @@ static void Main()
// Create struct instance and initialize by using "new".
// Memory is allocated on thread stack.
Person p1 = new Person("Alex", 9);
- Console.WriteLine("p1 Name = {0} Age = {1}", p1.Name, p1.Age);
+ Console.WriteLine($"p1 Name = {p1.Name} Age = {p1.Age}");
// Create new struct object. Note that struct can be initialized
// without using "new".
@@ -29,10 +29,10 @@ static void Main()
// Assign values to p2 members.
p2.Name = "Spencer";
p2.Age = 7;
- Console.WriteLine("p2 Name = {0} Age = {1}", p2.Name, p2.Age);
+ Console.WriteLine($"p2 Name = {p2.Name} Age = {p2.Age}");
// p1 values remain unchanged because p2 is copy.
- Console.WriteLine("p1 Name = {0} Age = {1}", p1.Name, p1.Age);
+ Console.WriteLine($"p1 Name = {p1.Name} Age = {p1.Age}");
}
}
/*
diff --git a/docs/csharp/fundamentals/object-oriented/snippets/objects/Program.cs b/docs/csharp/fundamentals/object-oriented/snippets/objects/Program.cs
index fd208fd6d57f4..3853079e5da10 100644
--- a/docs/csharp/fundamentals/object-oriented/snippets/objects/Program.cs
+++ b/docs/csharp/fundamentals/object-oriented/snippets/objects/Program.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
public class Person
{
@@ -17,7 +17,7 @@ class Program
static void Main()
{
Person person1 = new Person("Leopold", 6);
- Console.WriteLine("person1 Name = {0} Age = {1}", person1.Name, person1.Age);
+ Console.WriteLine($"person1 Name = {person1.Name} Age = {person1.Age}");
// Declare new person, assign person1 to it.
Person person2 = person1;
@@ -26,8 +26,8 @@ static void Main()
person2.Name = "Molly";
person2.Age = 16;
- Console.WriteLine("person2 Name = {0} Age = {1}", person2.Name, person2.Age);
- Console.WriteLine("person1 Name = {0} Age = {1}", person1.Name, person1.Age);
+ Console.WriteLine($"person2 Name = {person2.Name} Age = {person2.Age}");
+ Console.WriteLine($"person1 Name = {person1.Name} Age = {person1.Age}");
}
}
/*
diff --git a/docs/csharp/language-reference/keywords/snippets/ParameterModifiers.cs b/docs/csharp/language-reference/keywords/snippets/ParameterModifiers.cs
index 0a0a082846c1c..f85e04d48ce3b 100644
--- a/docs/csharp/language-reference/keywords/snippets/ParameterModifiers.cs
+++ b/docs/csharp/language-reference/keywords/snippets/ParameterModifiers.cs
@@ -1,4 +1,4 @@
-namespace Keywords;
+namespace Keywords;
internal class ParameterModifiers
{
@@ -9,17 +9,17 @@ internal static void ParamPassingExamples()
// Passing a variable by value means passing a copy of the variable.
// n1 is a value type
int n1 = 5;
- System.Console.WriteLine("The value before calling the method: {0}", n1);
+ System.Console.WriteLine($"The value before calling the method: {n1}");
SquareItValue(n1); // Passing the variable by value.
- System.Console.WriteLine("The value after calling the method: {0}", n1);
+ System.Console.WriteLine($"The value after calling the method: {n1}");
static void SquareItValue(int x)
// The parameter x is passed by value.
// Changes to x will not affect the original value of x.
{
x *= x;
- System.Console.WriteLine("The value inside the method: {0}", x);
+ System.Console.WriteLine($"The value inside the method: {x}");
}
/* Output:
The value before calling the method: 5
@@ -49,17 +49,17 @@ static void ChangeValue(int[] pArray)
// Passing a value by reference means passing a reference to the variable.
// n is a value type
int n2 = 5;
- System.Console.WriteLine("The value before calling the method: {0}", n2);
+ System.Console.WriteLine($"The value before calling the method: {n2}");
SquareItReference(ref n2); // Passing the variable by reference.
- System.Console.WriteLine("The value after calling the method: {0}", n2);
+ System.Console.WriteLine($"The value after calling the method: {n2}");
static void SquareItReference(ref int x)
// The parameter x is passed by reference.
// Changes to x will affect the original value of x.
{
x *= x;
- System.Console.WriteLine("The value inside the method: {0}", x);
+ System.Console.WriteLine($"The value inside the method: {x}");
}
/* Output:
The value before calling the method: 5
diff --git a/docs/csharp/language-reference/snippets/unsafe-code/Conversions.cs b/docs/csharp/language-reference/snippets/unsafe-code/Conversions.cs
index d3936b484392f..766d41dc2613d 100644
--- a/docs/csharp/language-reference/snippets/unsafe-code/Conversions.cs
+++ b/docs/csharp/language-reference/snippets/unsafe-code/Conversions.cs
@@ -20,7 +20,7 @@ public static void Conversions()
p++;
}
System.Console.WriteLine();
- System.Console.WriteLine("The value of the integer: {0}", number);
+ System.Console.WriteLine($"The value of the integer: {number}");
/* Output:
The 4 bytes of the integer: 00 04 00 00
diff --git a/docs/csharp/linq/get-started/snippets/WalkthroughWritingLinqQueries/Program.cs b/docs/csharp/linq/get-started/snippets/WalkthroughWritingLinqQueries/Program.cs
index ec723d730b08d..19734db556f07 100644
--- a/docs/csharp/linq/get-started/snippets/WalkthroughWritingLinqQueries/Program.cs
+++ b/docs/csharp/linq/get-started/snippets/WalkthroughWritingLinqQueries/Program.cs
@@ -1,4 +1,4 @@
-//
+//
using WalkthroughWritingLinqQueries;
// Create a data source by using a collection initializer.
@@ -237,7 +237,7 @@ from student in students
select totalScore;
double averageScore = studentQuery.Average();
- Console.WriteLine("Class average score = {0}", averageScore);
+ Console.WriteLine($"Class average score = {averageScore}");
// Output:
// Class average score = 334.166666666667
diff --git a/docs/csharp/linq/standard-query-operators/snippets/standard-query-operators/IndexExamples.cs b/docs/csharp/linq/standard-query-operators/snippets/standard-query-operators/IndexExamples.cs
index 00fd4e27b6218..fb76694839ed6 100644
--- a/docs/csharp/linq/standard-query-operators/snippets/standard-query-operators/IndexExamples.cs
+++ b/docs/csharp/linq/standard-query-operators/snippets/standard-query-operators/IndexExamples.cs
@@ -1,4 +1,4 @@
-using System.Xml.Linq;
+using System.Xml.Linq;
namespace StandardQueryOperators;
@@ -34,7 +34,7 @@ orderby gr.Key
foreach (var obj in query)
{
- Console.WriteLine("Words of length {0}:", obj.Length);
+ Console.WriteLine($"Words of length {obj.Length}:");
foreach (string word in obj.Words)
Console.WriteLine(word);
}
diff --git a/docs/csharp/programming-guide/classes-and-structs/snippets/how-to-declare-and-use-read-write-properties/Program.cs b/docs/csharp/programming-guide/classes-and-structs/snippets/how-to-declare-and-use-read-write-properties/Program.cs
index 3797d553625aa..80915a7794541 100644
--- a/docs/csharp/programming-guide/classes-and-structs/snippets/how-to-declare-and-use-read-write-properties/Program.cs
+++ b/docs/csharp/programming-guide/classes-and-structs/snippets/how-to-declare-and-use-read-write-properties/Program.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
namespace Properties
{
@@ -74,20 +74,20 @@ static void Main()
Person person = new Person();
// Print out the name and the age associated with the person:
- Console.WriteLine("Person details - {0}", person);
+ Console.WriteLine($"Person details - {person}");
// Set some values on the person object:
//
person.Name = "Joe";
person.Age = 99;
//
- Console.WriteLine("Person details - {0}", person);
+ Console.WriteLine($"Person details - {person}");
// Increment the Age property:
//
person.Age += 1;
//
- Console.WriteLine("Person details - {0}", person);
+ Console.WriteLine($"Person details - {person}");
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
diff --git a/docs/csharp/programming-guide/classes-and-structs/snippets/how-to-implement-and-call-a-custom-extension-method/Program.cs b/docs/csharp/programming-guide/classes-and-structs/snippets/how-to-implement-and-call-a-custom-extension-method/Program.cs
index 000548409e47b..963b4e6c01aaa 100644
--- a/docs/csharp/programming-guide/classes-and-structs/snippets/how-to-implement-and-call-a-custom-extension-method/Program.cs
+++ b/docs/csharp/programming-guide/classes-and-structs/snippets/how-to-implement-and-call-a-custom-extension-method/Program.cs
@@ -1,11 +1,11 @@
-using CustomExtensions;
+using CustomExtensions;
string s = "The quick brown fox jumped over the lazy dog.";
// Call the method as if it were an
// instance method on the type. Note that the first
// parameter is not specified by the calling code.
int i = s.WordCount();
-System.Console.WriteLine("Word count of s is {0}", i);
+System.Console.WriteLine($"Word count of s is {i}");
namespace CustomExtensions
diff --git a/docs/csharp/programming-guide/classes-and-structs/snippets/methods/Program.cs b/docs/csharp/programming-guide/classes-and-structs/snippets/methods/Program.cs
index b9a0906d8a6a8..6c70bd2eeeb55 100644
--- a/docs/csharp/programming-guide/classes-and-structs/snippets/methods/Program.cs
+++ b/docs/csharp/programming-guide/classes-and-structs/snippets/methods/Program.cs
@@ -1,4 +1,4 @@
-//
+//
abstract class Motorcycle
{
// Anyone can call this.
@@ -31,7 +31,7 @@ static void Main()
moto.AddGas(15);
moto.Drive(5, 20);
double speed = moto.GetTopSpeed();
- Console.WriteLine("My top speed is {0}", speed);
+ Console.WriteLine($"My top speed is {speed}");
}
}
//
diff --git a/docs/csharp/programming-guide/classes-and-structs/snippets/private-constructors/Program.cs b/docs/csharp/programming-guide/classes-and-structs/snippets/private-constructors/Program.cs
index 9d3dfda3ce115..401969c2d0e3c 100644
--- a/docs/csharp/programming-guide/classes-and-structs/snippets/private-constructors/Program.cs
+++ b/docs/csharp/programming-guide/classes-and-structs/snippets/private-constructors/Program.cs
@@ -1,4 +1,4 @@
-//
+//
class NLog
{
// Private Constructor:
@@ -33,7 +33,7 @@ static void Main()
Counter.currentCount = 100;
Counter.IncrementCount();
- Console.WriteLine("New count: {0}", Counter.currentCount);
+ Console.WriteLine($"New count: {Counter.currentCount}");
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
diff --git a/docs/csharp/programming-guide/classes-and-structs/snippets/properties/HidingProperty.cs b/docs/csharp/programming-guide/classes-and-structs/snippets/properties/HidingProperty.cs
index b53e23288a2cb..90816192f2c1c 100644
--- a/docs/csharp/programming-guide/classes-and-structs/snippets/properties/HidingProperty.cs
+++ b/docs/csharp/programming-guide/classes-and-structs/snippets/properties/HidingProperty.cs
@@ -1,4 +1,4 @@
-namespace HidingExample;
+namespace HidingExample;
//
public class Employee
{
@@ -38,8 +38,8 @@ public static void Test()
((Employee)m1).Name = "Mary";
//
- System.Console.WriteLine("Name in the derived class is: {0}", m1.Name);
- System.Console.WriteLine("Name in the base class is: {0}", ((Employee)m1).Name);
+ System.Console.WriteLine($"Name in the derived class is: {m1.Name}");
+ System.Console.WriteLine($"Name in the base class is: {((Employee)m1).Name}");
}
}
/* Output:
diff --git a/docs/csharp/programming-guide/classes-and-structs/snippets/properties/interfaces.cs b/docs/csharp/programming-guide/classes-and-structs/snippets/properties/interfaces.cs
index 7ca67720c05d7..65b6a3d122509 100644
--- a/docs/csharp/programming-guide/classes-and-structs/snippets/properties/interfaces.cs
+++ b/docs/csharp/programming-guide/classes-and-structs/snippets/properties/interfaces.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
namespace interfaces
{
@@ -93,8 +93,8 @@ public static void Examples()
e1.Name = System.Console.ReadLine();
System.Console.WriteLine("The employee information:");
- System.Console.WriteLine("Employee number: {0}", e1.Counter);
- System.Console.WriteLine("Employee name: {0}", e1.Name);
+ System.Console.WriteLine($"Employee number: {e1.Counter}");
+ System.Console.WriteLine($"Employee name: {e1.Name}");
//
}
}
diff --git a/docs/csharp/programming-guide/classes-and-structs/snippets/static-classes-and-static-class-members/Program.cs b/docs/csharp/programming-guide/classes-and-structs/snippets/static-classes-and-static-class-members/Program.cs
index 26b8f3fc8e35b..92ca7636bdfcc 100644
--- a/docs/csharp/programming-guide/classes-and-structs/snippets/static-classes-and-static-class-members/Program.cs
+++ b/docs/csharp/programming-guide/classes-and-structs/snippets/static-classes-and-static-class-members/Program.cs
@@ -1,4 +1,4 @@
-//
+//
public static class TemperatureConverter
{
public static double CelsiusToFahrenheit(string temperatureCelsius)
@@ -41,13 +41,13 @@ static void Main()
case "1":
Console.Write("Please enter the Celsius temperature: ");
F = TemperatureConverter.CelsiusToFahrenheit(Console.ReadLine() ?? "0");
- Console.WriteLine("Temperature in Fahrenheit: {0:F2}", F);
+ Console.WriteLine($"Temperature in Fahrenheit: {F:F2}");
break;
case "2":
Console.Write("Please enter the Fahrenheit temperature: ");
C = TemperatureConverter.FahrenheitToCelsius(Console.ReadLine() ?? "0");
- Console.WriteLine("Temperature in Celsius: {0:F2}", C);
+ Console.WriteLine($"Temperature in Celsius: {C:F2}");
break;
default:
diff --git a/docs/csharp/programming-guide/classes-and-structs/snippets/static-constructors/Program.cs b/docs/csharp/programming-guide/classes-and-structs/snippets/static-constructors/Program.cs
index b08f81b94da6a..d7e912fa0ca35 100644
--- a/docs/csharp/programming-guide/classes-and-structs/snippets/static-constructors/Program.cs
+++ b/docs/csharp/programming-guide/classes-and-structs/snippets/static-constructors/Program.cs
@@ -1,4 +1,4 @@
-//
+//
class SimpleClass
{
// Static variable that must be initialized at run time.
@@ -39,7 +39,7 @@ static Bus()
public Bus(int routeNum)
{
RouteNumber = routeNum;
- Console.WriteLine("Bus #{0} is created.", RouteNumber);
+ Console.WriteLine($"Bus #{RouteNumber} is created.");
}
// Instance method.
diff --git a/docs/csharp/programming-guide/statements-expressions-operators/snippets/how-to-define-value-equality-for-a-type/ValueEqualityClass/Program.cs b/docs/csharp/programming-guide/statements-expressions-operators/snippets/how-to-define-value-equality-for-a-type/ValueEqualityClass/Program.cs
index 1bdfd85c65b4d..a222ad8c361d1 100644
--- a/docs/csharp/programming-guide/statements-expressions-operators/snippets/how-to-define-value-equality-for-a-type/ValueEqualityClass/Program.cs
+++ b/docs/csharp/programming-guide/statements-expressions-operators/snippets/how-to-define-value-equality-for-a-type/ValueEqualityClass/Program.cs
@@ -1,4 +1,4 @@
-namespace ValueEqualityClass;
+namespace ValueEqualityClass;
class TwoDPoint : IEquatable
{
@@ -138,14 +138,14 @@ static void Main(string[] args)
int i = 5;
Console.WriteLine("pointA.Equals(pointB) = {0}", pointA.Equals(pointB));
- Console.WriteLine("pointA == pointB = {0}", pointA == pointB);
+ Console.WriteLine($"pointA == pointB = {pointA == pointB}");
Console.WriteLine("null comparison = {0}", pointA.Equals(pointC));
Console.WriteLine("Compare to some other type = {0}", pointA.Equals(i));
TwoDPoint pointD = null;
TwoDPoint pointE = null;
- Console.WriteLine("Two null TwoDPoints are equal: {0}", pointD == pointE);
+ Console.WriteLine($"Two null TwoDPoints are equal: {pointD == pointE}");
pointE = new TwoDPoint(3, 4);
Console.WriteLine("(pointE == pointA) = {0}", pointE == pointA);
diff --git a/docs/csharp/programming-guide/statements-expressions-operators/snippets/how-to-define-value-equality-for-a-type/ValueEqualityStruct/Program.cs b/docs/csharp/programming-guide/statements-expressions-operators/snippets/how-to-define-value-equality-for-a-type/ValueEqualityStruct/Program.cs
index 83b0589f287ec..a0dc9d0974ea5 100644
--- a/docs/csharp/programming-guide/statements-expressions-operators/snippets/how-to-define-value-equality-for-a-type/ValueEqualityStruct/Program.cs
+++ b/docs/csharp/programming-guide/statements-expressions-operators/snippets/how-to-define-value-equality-for-a-type/ValueEqualityStruct/Program.cs
@@ -1,4 +1,4 @@
-namespace ValueEqualityStruct
+namespace ValueEqualityStruct
{
struct TwoDPoint : IEquatable
{
@@ -38,7 +38,7 @@ static void Main(string[] args)
// True:
Console.WriteLine("pointA.Equals(pointB) = {0}", pointA.Equals(pointB));
// True:
- Console.WriteLine("pointA == pointB = {0}", pointA == pointB);
+ Console.WriteLine($"pointA == pointB = {pointA == pointB}");
// True:
Console.WriteLine("object.Equals(pointA, pointB) = {0}", object.Equals(pointA, pointB));
// False:
@@ -50,7 +50,7 @@ static void Main(string[] args)
// False:
Console.WriteLine("pointA.Equals(i) = {0}", pointA.Equals(i));
// CS0019:
- // Console.WriteLine("pointA == i = {0}", pointA == i);
+ // Console.WriteLine($"pointA == i = {pointA == i}");
// Compare unboxed to boxed.
System.Collections.ArrayList list = new System.Collections.ArrayList();
@@ -64,7 +64,7 @@ static void Main(string[] args)
// False:
Console.WriteLine("pointA == (pointC = null) = {0}", pointA == pointC);
// True:
- Console.WriteLine("pointC == pointD = {0}", pointC == pointD);
+ Console.WriteLine($"pointC == pointD = {pointC == pointD}");
TwoDPoint temp = new TwoDPoint(3, 4);
pointC = temp;
diff --git a/docs/csharp/programming-guide/statements-expressions-operators/snippets/how-to-test-for-reference-equality-identity/Program.cs b/docs/csharp/programming-guide/statements-expressions-operators/snippets/how-to-test-for-reference-equality-identity/Program.cs
index 91854f04b0ad0..08277bdfac616 100644
--- a/docs/csharp/programming-guide/statements-expressions-operators/snippets/how-to-test-for-reference-equality-identity/Program.cs
+++ b/docs/csharp/programming-guide/statements-expressions-operators/snippets/how-to-test-for-reference-equality-identity/Program.cs
@@ -1,4 +1,4 @@
-using System.Text;
+using System.Text;
namespace TestReferenceEquality
{
@@ -44,7 +44,7 @@ static void Main()
// that have reference equality also have value equality.
tcA.Num = 42;
tcA.Name = "TestClass 42";
- Console.WriteLine("tcB.Name = {0} tcB.Num: {1}", tcB.Name, tcB.Num);
+ Console.WriteLine($"tcB.Name = {tcB.Name} tcB.Num: {tcB.Num}");
#endregion
// Demonstrate that two value type instances never have reference equality.
@@ -71,7 +71,7 @@ static void Main()
// After a new string is assigned to strA, strA and strB
// are no longer interned and no longer have reference equality.
strA = "Goodbye world!";
- Console.WriteLine("strA = \"{0}\" strB = \"{1}\"", strA, strB);
+ Console.WriteLine($"strA = '{strA}' strB = '{strB}'");
Console.WriteLine("After strA changes, ReferenceEquals(strA, strB) = {0}",
Object.ReferenceEquals(strA, strB)); // false
@@ -84,7 +84,7 @@ static void Main()
Object.ReferenceEquals(stringC, strB));
// The string class overloads the == operator to perform an equality comparison.
- Console.WriteLine("stringC == strB = {0}", stringC == strB); // true
+ Console.WriteLine($"stringC == strB = {stringC == strB}"); // true
#endregion
diff --git a/docs/csharp/programming-guide/strings/snippets/StringParsing.cs b/docs/csharp/programming-guide/strings/snippets/StringParsing.cs
index fcf276f684c8d..f2b0b7d5332c7 100644
--- a/docs/csharp/programming-guide/strings/snippets/StringParsing.cs
+++ b/docs/csharp/programming-guide/strings/snippets/StringParsing.cs
@@ -13,7 +13,7 @@ public static void ParseNumericStrings()
long number1 = 0;
bool canConvert = long.TryParse(numString, out number1);
if (canConvert == true)
- Console.WriteLine("number1 now = {0}", number1);
+ Console.WriteLine($"number1 now = {number1}");
else
Console.WriteLine("numString is not a valid long");
@@ -21,7 +21,7 @@ public static void ParseNumericStrings()
numString = "255"; // A value of 256 will return false
canConvert = byte.TryParse(numString, out number2);
if (canConvert == true)
- Console.WriteLine("number2 now = {0}", number2);
+ Console.WriteLine($"number2 now = {number2}");
else
Console.WriteLine("numString is not a valid byte");
@@ -29,7 +29,7 @@ public static void ParseNumericStrings()
numString = "27.3"; //"27" is also a valid decimal
canConvert = decimal.TryParse(numString, out number3);
if (canConvert == true)
- Console.WriteLine("number3 now = {0}", number3);
+ Console.WriteLine($"number3 now = {number3}");
else
Console.WriteLine("number3 is not a valid decimal");
//
diff --git a/docs/csharp/snippets/methods/methods40.cs b/docs/csharp/snippets/methods/methods40.cs
index c327914a8052c..7cf5ef34643b9 100644
--- a/docs/csharp/snippets/methods/methods40.cs
+++ b/docs/csharp/snippets/methods/methods40.cs
@@ -1,4 +1,4 @@
-//
+//
namespace MotorCycleExample
{
abstract class Motorcycle
@@ -35,7 +35,7 @@ static void Main()
moto.AddGas(15);
_ = moto.Drive(5, 20);
double speed = moto.GetTopSpeed();
- Console.WriteLine("My top speed is {0}", speed);
+ Console.WriteLine($"My top speed is {speed}");
}
}
//
diff --git a/docs/csharp/snippets/methods/named1.cs b/docs/csharp/snippets/methods/named1.cs
index 7c26769f9461c..ce3cd89169773 100644
--- a/docs/csharp/snippets/methods/named1.cs
+++ b/docs/csharp/snippets/methods/named1.cs
@@ -1,4 +1,4 @@
-//
+//
namespace NamedMotorCycle;
class TestMotorcycle : Motorcycle
@@ -14,7 +14,7 @@ static void Main()
moto.StartEngine();
moto.AddGas(15);
int travelTime = moto.Drive(speed: 60, miles: 170);
- Console.WriteLine("Travel time: approx. {0} hours", travelTime);
+ Console.WriteLine($"Travel time: approx. {travelTime} hours");
}
}
// The example displays the following output:
diff --git a/docs/csharp/snippets/methods/named2.cs b/docs/csharp/snippets/methods/named2.cs
index 1e3df9d9f175e..4a80d42f5b1db 100644
--- a/docs/csharp/snippets/methods/named2.cs
+++ b/docs/csharp/snippets/methods/named2.cs
@@ -1,4 +1,4 @@
-class TestMotorcycle : Motorcycle
+class TestMotorcycle : Motorcycle
{
public override int Drive(int miles, int speed) =>
(int)Math.Round(((double)miles) / speed, 0);
@@ -13,7 +13,7 @@ static void Main()
//
int travelTime = moto.Drive(170, speed: 55);
//
- Console.WriteLine("Travel time: approx. {0} hours", travelTime);
+ Console.WriteLine($"Travel time: approx. {travelTime} hours");
}
}
diff --git a/docs/csharp/snippets/methods/swap107.cs b/docs/csharp/snippets/methods/swap107.cs
index 28ee2506242aa..d051b2af58429 100644
--- a/docs/csharp/snippets/methods/swap107.cs
+++ b/docs/csharp/snippets/methods/swap107.cs
@@ -1,15 +1,15 @@
-//
+//
public static class RefSwapExample
{
static void Main()
{
int i = 2, j = 3;
- Console.WriteLine("i = {0} j = {1}", i, j);
+ Console.WriteLine($"i = {i} j = {j}");
Swap(ref i, ref j);
- Console.WriteLine("i = {0} j = {1}", i, j);
+ Console.WriteLine($"i = {i} j = {j}");
}
static void Swap(ref int x, ref int y) =>
diff --git a/docs/csharp/whats-new/csharp-14.md b/docs/csharp/whats-new/csharp-14.md
index ad68a7a62985f..a6cf98faab19d 100644
--- a/docs/csharp/whats-new/csharp-14.md
+++ b/docs/csharp/whats-new/csharp-14.md
@@ -97,7 +97,7 @@ Partial constructors and partial events must include exactly one *defining decla
Only the implementing declaration of a partial constructor can include a constructor initializer: `this()` or `base()`. Only one partial type declaration can include the primary constructor syntax.
-The implementing declaration of a partial event must include `get` and `remove` accessors. The defining declaration declares a field-like event.
+The implementing declaration of a partial event must include `add` and `remove` accessors. The defining declaration declares a field-like event.
## See also