[Everyday C# - 12] Strings: concatenate, modify, compare, interpolation tutorial#54097
Closed
BillWagner wants to merge 14 commits into
Closed
[Everyday C# - 12] Strings: concatenate, modify, compare, interpolation tutorial#54097BillWagner wants to merge 14 commits into
BillWagner wants to merge 14 commits into
Conversation
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.
Contributor
There was a problem hiding this comment.
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull three string how-tos into the Fundamentals
common-tasks/group, move the interpolation tutorial intofundamentals/tutorials/, and redistribute deep-dive material into the language-referencestring-operations.mdpage that PR 11 introduced. Pattern mirrors PR 11 (#53991) exactly.Internal previews
Toggle expand/collapse
+and+=$