Skip to content

Commit a78c8bc

Browse files
anandmeggewarrenBillWagner
authored
Update ms.custom value to the new value and add addl. highlights (#44580)
* Update ms.custom value to the new value * Update ms.custom in deserialization.md * Update ms.custom in how-to.md * Update ms.custom in customize-properties.md * Update ms.custom in migrate-from-newtonsoft.md * Update how-to-convert-a-string-to-a-number.md * Add Copilot highlight to how-to-initialize-a-dictionary-with-a-collection-initializer.md * Update how-to-initialize-a-dictionary-with-a-collection-initializer.md * Add copilot highlight to concatenate-multiple-strings.md * Update docs/csharp/programming-guide/classes-and-structs/how-to-initialize-a-dictionary-with-a-collection-initializer.md Co-authored-by: Genevieve Warren <[email protected]> * Update docs/csharp/programming-guide/classes-and-structs/how-to-initialize-a-dictionary-with-a-collection-initializer.md Co-authored-by: Bill Wagner <[email protected]> --------- Co-authored-by: Genevieve Warren <[email protected]> Co-authored-by: Bill Wagner <[email protected]>
1 parent a1b948b commit a78c8bc

File tree

8 files changed

+46
-8
lines changed

8 files changed

+46
-8
lines changed

docs/csharp/how-to/concatenate-multiple-strings.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
---
22
title: "How to concatenate multiple strings"
33
description: There are multiple ways to concatenate strings in C#. Learn the options and the reasons behind different choices.
4-
ms.date: 11/22/2024
4+
ms.date: 1/31/2025
55
helpviewer_keywords:
66
- "joining strings [C#]"
77
- "concatenating strings [C#]"
88
- "strings [C#], concatenation"
9+
ms.collection: ce-skilling-ai-copilot
10+
ms.custom: copilot-scenario-highlight
911
---
1012
# How to concatenate multiple strings (C# Guide)
1113

1214
*Concatenation* is the process of appending one string to the end of another string. You concatenate strings by using the `+` operator. For string literals and string constants, concatenation occurs at compile time; no run-time concatenation occurs. For string variables, concatenation occurs only at run time.
1315

1416
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note.md)]
1517

18+
> [!TIP]
19+
> You can use AI assistance to [concatenate strings with GitHub Copilot](#use-github-copilot-to-concatenate-strings).
20+
1621
## String literals
1722

1823
The following example splits a long string literal into smaller strings to improve readability in the source code. The code concatenates the smaller strings to create the long string literal. The parts are concatenated into a single string at compile time. There's no run-time performance cost regardless of the number of strings involved.
@@ -66,6 +71,20 @@ combines an array of words, adding a space between each word in the array:
6671

6772
This option can cause more allocations than other methods for concatenating collections, as it creates an intermediate string for each iteration. If optimizing performance is critical, consider the [`StringBuilder`](#stringbuilder) class or the [`String.Concat` or `String.Join`](#stringconcat-or-stringjoin) method to concatenate a collection, instead of `Enumerable.Aggregate`.
6873

74+
## Use GitHub Copilot to concatenate strings
75+
76+
You can use GitHub Copilot in your IDE to generate C# code to concatenate multiple strings. You can customize the prompt to specify strings and the method to use per your requirements.
77+
78+
The following text shows an example prompt for Copilot Chat:
79+
80+
```copilot-prompt
81+
Generate C# code to use String.Format to build an output string "Hi x, today's date is y. You are z years old." where x is "John", y is today's date and z is the birthdate January 1, 2000. The final string should show date in the full format mm/dd/yyyy. Show output.
82+
```
83+
84+
GitHub Copilot is powered by AI, so surprises and mistakes are possible. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs).
85+
86+
Learn more about [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states) and [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview).
87+
6988
## See also
7089

7190
- <xref:System.String>

docs/csharp/how-to/parse-strings-using-split.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ helpviewer_keywords:
88
- "strings [C#], splitting"
99
- "parse strings"
1010
ms.assetid: 729c2923-4169-41c6-9c90-ef176c1e2953
11-
ms.custom: mvc, vs-copilot-horizontal
11+
ms.custom: mvc, copilot-scenario-highlight
1212
ms.collection: ce-skilling-ai-copilot
1313
---
1414
# How to separate strings using String.Split in C\#

docs/csharp/programming-guide/classes-and-structs/how-to-initialize-a-dictionary-with-a-collection-initializer.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
---
22
title: "How to initialize a dictionary with a collection initializer"
33
description: Learn how to initialize a dictionary in C#, using either the Add method or an index initializer. This example shows both options.
4-
ms.date: 03/15/2024
4+
ms.date: 01/31/2025
55
helpviewer_keywords:
66
- "collection initializers [C#], with Dictionary"
77
ms.topic: how-to
8+
ms.collection: ce-skilling-ai-copilot
9+
ms.custom: copilot-scenario-highlight
810
ms.assetid: 25283922-f8ee-40dc-a639-fac30804ec71
911
---
1012
# How to initialize a dictionary with a collection initializer (C# Programming Guide)
@@ -22,6 +24,9 @@ A <xref:System.Collections.Generic.Dictionary%602> contains a collection of key/
2224
> <xref:System.Collections.Generic.Dictionary%602.Add%2A> method will throw <xref:System.ArgumentException>: `'An item with the same key has already been added. Key: 111'`,
2325
> while the second part of example, the public read / write indexer method, will quietly overwrite the already existing entry with the same key.
2426
27+
> [!TIP]
28+
> You can use AI assistance to [initialize a dictionary with GitHub Copilot](#use-github-copilot-to-initialize-a-dictionary).
29+
2530
## Example
2631
2732
In the following code example, a <xref:System.Collections.Generic.Dictionary%602> is initialized with instances of type `StudentName`. The first initialization uses the `Add` method with two arguments. The compiler generates a call to `Add` for each of the pairs of `int` keys and `StudentName` values. The second uses a public read / write indexer method of the `Dictionary` class:
@@ -30,6 +35,20 @@ In the following code example, a <xref:System.Collections.Generic.Dictionary%602
3035
3136
Note the two pairs of braces in each element of the collection in the first declaration. The innermost braces enclose the object initializer for the `StudentName`, and the outermost braces enclose the initializer for the key/value pair to be added to the `students` <xref:System.Collections.Generic.Dictionary%602>. Finally, the whole collection initializer for the dictionary is enclosed in braces. In the second initialization, the left side of the assignment is the key and the right side is the value, using an object initializer for `StudentName`.
3237
38+
## Use GitHub Copilot to initialize a dictionary
39+
40+
You can use GitHub Copilot in your IDE to generate C# code to initialize a dictionary with a collection initializer. You can customize the prompt to add specifics per your requirements.
41+
42+
The following text shows an example prompt for Copilot Chat:
43+
44+
```copilot-prompt
45+
Generate C# code to initialize Dictionary<int, Employee> using key-value pairs within the collection initializer. The employee class is a record class with two properties: Name and Age.
46+
```
47+
48+
GitHub Copilot is powered by AI, so surprises and mistakes are possible. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs).
49+
50+
Learn more about [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states) and [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview).
51+
3352
## See also
3453
3554
- [Object and Collection Initializers](./object-and-collection-initializers.md)

docs/csharp/programming-guide/types/how-to-convert-a-string-to-a-number.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ helpviewer_keywords:
99
- "strings [C#], converting to int"
1010
ms.topic: how-to
1111
ms.collection: ce-skilling-ai-copilot
12-
ms.custom: vs-copilot-horizontal
12+
ms.custom: copilot-scenario-highlight
1313
ms.assetid: 467b9979-86ee-4afd-b734-30299cda91e3
1414
adobe-target: true
1515
---

docs/standard/serialization/system-text-json/customize-properties.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ helpviewer_keywords:
1313
- "objects, serializing"
1414
ms.topic: how-to
1515
ms.collection: ce-skilling-ai-copilot
16-
ms.custom: vs-copilot-horizontal
16+
ms.custom: copilot-scenario-highlight
1717
---
1818

1919
# How to customize property names and values with System.Text.Json

docs/standard/serialization/system-text-json/deserialization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ helpviewer_keywords:
1212
- "deserialization"
1313
ms.topic: concept-article
1414
ms.collection: ce-skilling-ai-copilot
15-
ms.custom: vs-copilot-horizontal
15+
ms.custom: copilot-scenario-highlight
1616
#customer intent: As a developer, I want to learn how to use System.Text.Json to deserialize JSON data.
1717
---
1818

docs/standard/serialization/system-text-json/how-to.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ helpviewer_keywords:
1313
- "objects, serializing"
1414
ms.topic: how-to
1515
ms.collection: ce-skilling-ai-copilot
16-
ms.custom: vs-copilot-horizontal
16+
ms.custom: copilot-scenario-highlight
1717
adobe-target: true
1818
---
1919

docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ helpviewer_keywords:
1111
ms.topic: how-to
1212
zone_pivot_groups: dotnet-version
1313
ms.collection: ce-skilling-ai-copilot
14-
ms.custom: vs-copilot-horizontal
14+
ms.custom: copilot-scenario-highlight
1515
---
1616

1717
# Migrate from Newtonsoft.Json to System.Text.Json

0 commit comments

Comments
 (0)