Skip to content

[Everyday C# - 12] Strings: concatenate, modify, compare, interpolation tutorial#54097

Closed
BillWagner wants to merge 14 commits into
dotnet:mainfrom
BillWagner:strings-actions-tutorial
Closed

[Everyday C# - 12] Strings: concatenate, modify, compare, interpolation tutorial#54097
BillWagner wants to merge 14 commits into
dotnet:mainfrom
BillWagner:strings-actions-tutorial

Conversation

@BillWagner
Copy link
Copy Markdown
Member

@BillWagner BillWagner commented May 29, 2026

Pull three string how-tos into the Fundamentals common-tasks/ group, move the interpolation tutorial into fundamentals/tutorials/, and redistribute deep-dive material into the language-reference string-operations.md page that PR 11 introduced. Pattern mirrors PR 11 (#53991) exactly.


Internal previews

Toggle expand/collapse
📄 File 🔗 Preview link
docs/core/extensions/logging/library-guidance.md Logging guidance for .NET library authors
docs/csharp/advanced-topics/update-applications/nullable-migration-strategies.md Nullable migration strategies
docs/csharp/fundamentals/null-safety/common-tasks/resolve-warnings.md Resolve nullable warnings
docs/csharp/fundamentals/null-safety/nullable-reference-types.md Nullable reference types
docs/csharp/fundamentals/strings/common-tasks/compare.md docs/csharp/fundamentals/strings/common-tasks/compare
docs/csharp/fundamentals/strings/common-tasks/concatenate.md Concatenate strings in C#
docs/csharp/fundamentals/strings/common-tasks/modify.md "Modify string contents in C#"
docs/csharp/fundamentals/strings/common-tasks/search.md Search strings in C#
docs/csharp/fundamentals/strings/common-tasks/split.md docs/csharp/fundamentals/strings/common-tasks/split
docs/csharp/fundamentals/strings/interpolation.md String interpolation in C#
docs/csharp/fundamentals/tutorials/nullable-reference-types.md Tutorial: Express your design intent with nullable and non-nullable reference types
docs/csharp/fundamentals/tutorials/string-interpolation.md "Tutorial: Learn string interpolation"
docs/csharp/how-to/index.md How to (C#)
docs/csharp/language-reference/builtin-types/string-operations.md String operations: pattern matching, performance, and span-based search
docs/csharp/language-reference/operators/addition-operator.md Addition operators - + and +=
docs/csharp/language-reference/operators/equality-operators.md Equality operators - test if two objects are equal or not
docs/csharp/language-reference/toc.yml docs/csharp/language-reference/toc
docs/csharp/language-reference/tokens/interpolated.md String interpolation using $
docs/csharp/programming-guide/strings/index.md "Strings"
docs/csharp/toc.yml Taken from https://github.com/dotnet/roslyn/wiki/Samples-and-Walkthroughs
docs/framework/performance/performance-tips.md docs/framework/performance/performance-tips
docs/fundamentals/code-analysis/quality-rules/ca1305.md CA1305: Specify IFormatProvider
docs/standard/base-types/best-practices-strings.md Best practices for comparing strings in .NET
docs/standard/base-types/divide-up-strings.md Separate strings into substrings

BillWagner and others added 14 commits May 28, 2026 11:48
Build the projects for this PR.
Build the main articles for this PR.
Move the advanced material into an appropriate language reference article.

This information doesn't fit the fundamentals goals, but is important for more advanced developers.
Remove (now) obsolete articles.
Add necessary redirects.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Review the major changes and edit / content review.
Create the common tasks section for what had been "How to" articles.
Do a final edit pass.
First draft of all changes for PR 12.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request continues the Everyday C# Fundamentals restructuring by moving the string “how-to” content into the Fundamentals > Strings > Common tasks area, relocating/refreshing the string interpolation tutorial, and adding a new language-reference page for deeper string operations content. It also updates TOCs, cross-links, and redirections to match the new information architecture.

Changes:

  • Added new Fundamentals string articles (search, split, concatenate, modify, compare) and new snippet projects targeting net10.0.
  • Added a new language-reference article for advanced string operations (regex, span-based search, and StringComparison) with supporting snippets.
  • Updated TOCs, cross-references across docs, removed old how-to pages/snippets, and added/adjusted redirections.

Reviewed changes

Copilot reviewed 53 out of 56 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
docs/standard/base-types/divide-up-strings.md Updates “See also” link to the new Fundamentals split article.
docs/standard/base-types/best-practices-strings.md Updates “See also” link to the new Fundamentals compare article.
docs/fundamentals/code-analysis/quality-rules/ca1305.md Updates interpolation tutorial link to the new location.
docs/framework/performance/performance-tips.md Updates concatenation guidance link to the new Fundamentals concatenate article.
docs/csharp/toc.yml Reorganizes Strings and Null safety nav, adds new pages, and relocates the interpolation tutorial entry.
docs/csharp/programming-guide/strings/index.md Repoints related-articles links to the new Fundamentals string common tasks pages and tutorial location.
docs/csharp/language-reference/tokens/interpolated.md Updates “new to interpolation” tutorial link to the new Fundamentals tutorial path.
docs/csharp/language-reference/toc.yml Adds new language-reference entry for “String operations”.
docs/csharp/language-reference/operators/equality-operators.md Updates compare-strings link to the new Fundamentals compare article.
docs/csharp/language-reference/operators/addition-operator.md Updates concatenate link to the new Fundamentals concatenate article.
docs/csharp/language-reference/builtin-types/string-operations.md Introduces a new language-reference deep-dive page for advanced string operations.
docs/csharp/language-reference/builtin-types/snippets/string-operations/string-operations.csproj Adds a new net10.0 snippet project for the language-reference article.
docs/csharp/language-reference/builtin-types/snippets/string-operations/Program.cs Adds executable snippets for regex, span search, comparisons, and string.Create.
docs/csharp/how-to/snippets/strings/strings.csproj Removes the old consolidated how-to snippet project.
docs/csharp/how-to/snippets/strings/SearchStrings.cs Removes the old how-to search snippets (content migrated).
docs/csharp/how-to/snippets/strings/Program.cs Removes the old how-to snippet runner.
docs/csharp/how-to/snippets/strings/ParseStringsUsingSplit.cs Removes the old how-to split snippets (content migrated).
docs/csharp/how-to/snippets/strings/ModifyStrings.cs Removes the old how-to modify snippets (content migrated).
docs/csharp/how-to/snippets/strings/Concatenate.cs Removes the old how-to concatenate snippets (content migrated).
docs/csharp/how-to/snippets/strings/CompareStrings.cs Removes the old how-to compare snippets (content migrated).
docs/csharp/how-to/search-strings.md Removes the old how-to article (replaced by Fundamentals common task + language reference).
docs/csharp/how-to/parse-strings-using-split.md Removes the old how-to article (replaced by Fundamentals common task).
docs/csharp/how-to/modify-string-contents.md Removes the old how-to article (replaced by Fundamentals common task).
docs/csharp/how-to/index.md Updates the how-to landing page links to point at the new Fundamentals common task pages.
docs/csharp/how-to/concatenate-multiple-strings.md Removes the old how-to article (replaced by Fundamentals common task).
docs/csharp/how-to/compare-strings.md Removes the old how-to article (replaced by Fundamentals common task).
docs/csharp/fundamentals/tutorials/string-interpolation.md Updates and relocates the interpolation tutorial (new frontmatter, paths, and snippet references).
docs/csharp/fundamentals/tutorials/snippets/string-interpolation/string-interpolation.csproj Updates tutorial snippet project to net10.0.
docs/csharp/fundamentals/tutorials/snippets/string-interpolation/Program.cs Refreshes tutorial snippet code (modern syntax and additional alignment call).
docs/csharp/fundamentals/tutorials/nullable-reference-types.md Updates related-content link to the new resolve-warnings location.
docs/csharp/fundamentals/strings/snippets/interpolation/Program.cs Adds a new Fundamentals “strings/interpolation” snippet set.
docs/csharp/fundamentals/strings/snippets/interpolation/interpolation.csproj Adds a new net10.0 snippet project for Fundamentals string interpolation article.
docs/csharp/fundamentals/strings/interpolation.md Adds a new Fundamentals string interpolation concept article.
docs/csharp/fundamentals/strings/common-tasks/split.md Adds new Fundamentals split article referencing new snippets.
docs/csharp/fundamentals/strings/common-tasks/snippets/split/split.csproj Adds a new net10.0 snippet project for split common task.
docs/csharp/fundamentals/strings/common-tasks/snippets/split/Program.cs Adds updated split examples as executable snippets.
docs/csharp/fundamentals/strings/common-tasks/snippets/search/search.csproj Adds a new net10.0 snippet project for search common task.
docs/csharp/fundamentals/strings/common-tasks/snippets/search/Program.cs Adds updated search examples as executable snippets.
docs/csharp/fundamentals/strings/common-tasks/snippets/modify/Program.cs Adds updated modify examples as executable snippets.
docs/csharp/fundamentals/strings/common-tasks/snippets/modify/modify.csproj Adds a new net10.0 snippet project for modify common task.
docs/csharp/fundamentals/strings/common-tasks/snippets/concatenate/Program.cs Adds updated concatenate examples as executable snippets.
docs/csharp/fundamentals/strings/common-tasks/snippets/concatenate/concatenate.csproj Adds a new net10.0 snippet project for concatenate common task.
docs/csharp/fundamentals/strings/common-tasks/snippets/compare/Program.cs Adds updated compare examples as executable snippets.
docs/csharp/fundamentals/strings/common-tasks/snippets/compare/compare.csproj Adds a new net10.0 snippet project for compare common task.
docs/csharp/fundamentals/strings/common-tasks/search.md Adds new Fundamentals search article referencing new snippets.
docs/csharp/fundamentals/strings/common-tasks/modify.md Adds new Fundamentals modify article referencing new snippets.
docs/csharp/fundamentals/strings/common-tasks/concatenate.md Adds new Fundamentals concatenate article referencing new snippets.
docs/csharp/fundamentals/strings/common-tasks/compare.md Adds new Fundamentals compare article referencing new snippets.
docs/csharp/fundamentals/null-safety/nullable-reference-types.md Updates link to resolve-warnings after moving it under common tasks.
docs/csharp/fundamentals/null-safety/common-tasks/snippets/resolve-warnings/resolve-warnings.csproj Adds a new net10.0 snippet project for resolve-warnings.
docs/csharp/fundamentals/null-safety/common-tasks/snippets/resolve-warnings/project-snippet.xml Adds a small project snippet used by the resolve-warnings article.
docs/csharp/fundamentals/null-safety/common-tasks/snippets/resolve-warnings/Program.cs Adds executable examples for common nullable warning patterns and fixes.
docs/csharp/fundamentals/null-safety/common-tasks/resolve-warnings.md Fixes relative links after the resolve-warnings move to common-tasks/.
docs/csharp/advanced-topics/update-applications/nullable-migration-strategies.md Updates links to resolve-warnings after the new common-tasks/ location.
docs/core/extensions/logging/library-guidance.md Updates string interpolation tutorial link to the new Fundamentals tutorial path.
.openpublishing.redirection.csharp.json Adds/adjusts redirections for moved/deleted pages.

},
{
"source_path_from_root": "/docs/csharp/how-to/parse-strings-using-split.md",
"redirect_url": "/dotnet/csharp/fundamentals/strings/split"
},
{
"source_path_from_root": "/docs/csharp/how-to/search-strings.md",
"redirect_url": "/dotnet/csharp/fundamentals/strings/search"

:::code language="csharp" source="snippets/search/Program.cs" id="contains":::

These methods default to **case-sensitive, ordinal** comparison. To accept user input or to ignore case for display text, pass a <xref:System.StringComparison> value such as <xref:System.StringComparison.CurrentCultureIgnoreCase?displayProperty=nameWithType> or <xref:System.StringComparison.OrdinalIgnoreCase?displayProperty=nameWithType>.
- If you're searching that same user-visible text and want to ignore case, use <xref:System.StringComparison.CurrentCultureIgnoreCase>.
- If you're searching persisted data that must compare the same on every machine and culture, use <xref:System.StringComparison.InvariantCulture> (rarely needed).

Ordinal comparison is the fastest option and the right default for anything that isn't natural-language text. Culture-aware comparison is significantly slower and can produce surprising results. For example, in some cultures the lowercase `i` doesn't match an uppercase `I`.Reserve it for searches that users perform against prose.

## Use a conditional expression

The colon has special meaning inside an interpolation expression, so wrap a [conditional exoressuin](../../language-reference/operators/conditional-operator.md) in parentheses:

## Build constant strings

You can build constant interpolated strings when every interpolated expression is a constant value.That makes it usable for attribute arguments, `switch` patterns, and other contexts that require compile-time constants:
Comment on lines +128 to +129
// Linguistic comparison folds 'ß' to "ss" in the invariant culture;
// ordinal comparison sees two distinct code points.
@BillWagner BillWagner closed this May 29, 2026
@BillWagner BillWagner deleted the strings-actions-tutorial branch May 29, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants