Skip to content

Modernize C# code snippets - System/Char, System/Console - #12950

Open
gewarren wants to merge 2 commits into
dotnet:mainfrom
gewarren:modernize-code-system-char
Open

Modernize C# code snippets - System/Char, System/Console#12950
gewarren wants to merge 2 commits into
dotnet:mainfrom
gewarren:modernize-code-system-char

Conversation

@gewarren

@gewarren gewarren commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Contributes to #12713.


Internal previews

Toggle expand/collapse
File Preview link
snippets/csharp/System/Char/CompareTo/compareto.cs Preview published page
snippets/csharp/System/Char/ConvertFromUtf32/utf.cs Preview published page
snippets/csharp/System/Char/Equals/equals.cs Preview published page
snippets/csharp/System/Char/GetNumericValue/getnumericvalue.cs Preview published page
snippets/csharp/System/Char/GetNumericValue/getnumericvalue1.cs Preview published page
snippets/csharp/System/Char/GetUnicodeCategory/getunicodecategory.cs Preview published page
snippets/csharp/System/Char/IsControl/IsControl1.cs Preview published page
snippets/csharp/System/Char/IsControl/IsControl2.cs Preview published page
snippets/csharp/System/Char/IsDigit/isdigit.cs Preview published page
snippets/csharp/System/Char/IsHighSurrogate/sur.cs Preview published page
snippets/csharp/System/Char/IsLetter/isletter.cs Preview published page
snippets/csharp/System/Char/IsLetterOrDigit/isletterordigit.cs Preview published page
snippets/csharp/System/Char/IsLower/islower.cs Preview published page
snippets/csharp/System/Char/IsNumber/isnumber.cs Preview published page
snippets/csharp/System/Char/IsNumber/isnumber1.cs Preview published page
snippets/csharp/System/Char/IsPunctuation/ispunctuation.cs Preview published page
snippets/csharp/System/Char/IsSeparator/isseparator.cs Preview published page
snippets/csharp/System/Char/IsSeparator/isseparator1.cs Preview published page
snippets/csharp/System/Char/IsSurrogate/issurrogate.cs Preview published page
snippets/csharp/System/Char/IsSymbol/issymbol.cs Preview published page
snippets/csharp/System/Char/IsWhiteSpace/iswhitespace.cs Preview published page
snippets/csharp/System/Char/Overview/charstructure.cs Preview published page
snippets/csharp/System/Char/Overview/GetUnicodeCategory3.cs Preview published page
snippets/csharp/System/Char/Overview/grapheme1.cs Preview published page
snippets/csharp/System/Char/Overview/surrogate1.cs Preview published page
snippets/csharp/System/Char/Overview/textelements2.cs Preview published page
snippets/csharp/System/Char/Overview/textelements2a.cs Preview published page
snippets/csharp/System/Char/Parse/parse.cs Preview published page
snippets/csharp/System/Char/ToLower/tolower.cs Preview published page
snippets/csharp/System/Char/ToString/tostring.cs Preview published page

Note

This table shows the first 30 preview links (sorted alphabetically by file path) found in the OPS build report. For the full list, select OpenPublishing.Build Details within checks.

Copilot AI review requested due to automatic review settings August 7, 2026 00:00
@gewarren
gewarren requested a review from a team as a code owner August 7, 2026 00:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR contributes to the ongoing snippet modernization effort (#12713) by updating C# snippets under snippets/csharp for System.Console- and System.Char-related APIs (plus adjacent ConsoleKeyInfo and CharEnumerator samples). The changes primarily modernize syntax (built-in type aliases, target-typed new, string interpolation) and normalize formatting without changing the APIs being demonstrated.

Changes:

  • Modernize snippet code style across the touched areas (aliases like string/char, target-typed new, interpolated strings, consistent braces/indentation).
  • Remove unused using directives and simplify a number of small constructs while preserving sample intent.
  • Update several output statements to interpolated strings for clarity.

Reviewed changes

Copilot reviewed 81 out of 88 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
snippets/csharp/System/ConsoleKeyInfo/KeyChar/keychar1.cs Modernizes formatting, type aliases, and output formatting while preserving sample behavior.
snippets/csharp/System/ConsoleKeyInfo/GetHashCode/hash.cs Applies consistent indentation and target-typed new in helper method.
snippets/csharp/System/ConsoleKeyInfo/Equals/equals.cs Applies consistent indentation and target-typed new in helper method.
snippets/csharp/System/ConsoleKey/Overview/ConsoleKey1.cs Updates string building to modern construction and normalizes flow formatting.
snippets/csharp/System/Console/WriteLine/WriteLine7.cs Refactors to expression-bodied Main while preserving the composite-format overload usage.
snippets/csharp/System/Console/WriteLine/WriteLine6.cs Uses target-typed new and normalizes loop formatting.
snippets/csharp/System/Console/WriteLine/writeline_obj1.cs Uses object[] aliasing and explicit foreach type; normalizes indentation.
snippets/csharp/System/Console/WriteLine/writeline_boolean1.cs Uses target-typed new, explicit foreach type, and normalizes formatting.
snippets/csharp/System/Console/WriteLine/tipcalc.cs Updates Double.TryParse to double.TryParse and normalizes file header.
snippets/csharp/System/Console/WriteLine/newline1.cs Normalizes indentation and brace style.
snippets/csharp/System/Console/Write/WriteParams2.cs Modernizes property types and object initialization formatting.
snippets/csharp/System/Console/Write/WriteParams1.cs Modernizes property types and object initialization formatting.
snippets/csharp/System/Console/Write/wl.cs Normalizes formatting and spacing for readability.
snippets/csharp/System/Console/Write/reformat.cs Normalizes spacing/indentation and uses built-in aliases in parsing.
snippets/csharp/System/Console/WindowLeft/windowleft1.cs Normalizes indentation and converts some output to interpolation.
snippets/csharp/System/Console/Title/mytitle.cs Updates output to interpolation and normalizes indentation.
snippets/csharp/System/Console/SetWindowSize/sws.cs Normalizes indentation and spacing (including arithmetic spacing).
snippets/csharp/System/Console/SetOut/source.cs Normalizes try/catch formatting and uses target-typed new for streams.
snippets/csharp/System/Console/SetError/SetError1.cs Removes unused using and modernizes output formatting.
snippets/csharp/System/Console/SetBufferSize/wlt.cs Large formatting normalization and minor modernizations (target-typed new).
snippets/csharp/System/Console/ReadLine/ReadLineSimple.cs Normalizes indentation and brace style.
snippets/csharp/System/Console/ReadLine/ReadLine3.cs Normalizes loop formatting and updates one output to interpolation.
snippets/csharp/System/Console/ReadLine/ReadLine2.cs Normalizes indentation and brace style.
snippets/csharp/System/Console/ReadKey/rkbool.cs Normalizes loop formatting and updates output to interpolation.
snippets/csharp/System/Console/ReadKey/rk.cs Normalizes indentation and spacing in modifier checks.
snippets/csharp/System/Console/ReadKey/ReadKey2.cs Updates timezone output to interpolation and normalizes formatting.
snippets/csharp/System/Console/ReadKey/ReadKey1.cs Updates timezone output to interpolation and normalizes formatting.
snippets/csharp/System/Console/Read/read.cs Modernizes aliases (char) and updates exception output to interpolation.
snippets/csharp/System/Console/Overview/unicode1.cs Uses interpolation and explicit foreach type; normalizes formatting.
snippets/csharp/System/Console/Overview/source.cs Normalizes file header and brace layout.
snippets/csharp/System/Console/Overview/setfont1.cs Modernizes formatting/constructors in unsafe interop example.
snippets/csharp/System/Console/Overview/normalize1.cs Removes unused using and uses modern construction syntax.
snippets/csharp/System/Console/Overview/fontlink1.cs Normalizes control flow formatting and spacing; retains registry logic.
snippets/csharp/System/Console/Overview/example3.cs Broad modernization of formatting and messaging in Unicode-range display sample.
snippets/csharp/System/Console/Out/out1.cs Uses object initializer style for StreamWriter and normalizes formatting.
snippets/csharp/System/Console/OpenStandardOutput/inserttabs.cs Normalizes formatting and uses object initializer for AutoFlush.
snippets/csharp/System/Console/OpenStandardInput/decode.cs Normalizes brace style for class and Main.
snippets/csharp/System/Console/KeyAvailable/ka.cs Normalizes loop formatting and updates one output to interpolation.
snippets/csharp/System/Console/In/consolein.cs Normalizes brace style, uses built-in aliases, and interpolated output.
snippets/csharp/System/Console/Error/viewtextfile.cs Modernizes aliases, stream construction, and some output formatting.
snippets/csharp/System/Console/Error/expandtabsex.cs Normalizes try/catch/loop formatting and modernizes writer initialization.
snippets/csharp/System/Console/Error/error1.cs Converts composite formatting to interpolation and normalizes loops.
snippets/csharp/System/Console/CursorVisible/vis.cs Normalizes spacing/braces and built-in alias usage.
snippets/csharp/System/Console/CursorSize/csize.cs Normalizes spacing/braces and array initializer formatting.
snippets/csharp/System/Console/Clear/lts.cs Normalizes indentation and spacing in helper and drawing logic.
snippets/csharp/System/Console/Clear/clear1.cs Normalizes indentation/braces and modernizes char alias usage.
snippets/csharp/System/Console/CancelKeyPress/ckp.cs Uses target-typed new for delegate construction.
snippets/csharp/System/Console/BufferHeight/hw.cs Converts composite formatting to interpolation.
snippets/csharp/System/Console/Beep/beep.cs Uses built-in aliases and interpolation; normalizes indentation.
snippets/csharp/System/Console/Beep/b2.cs Large formatting normalization and minor API modernizations (expression-bodied properties).
snippets/csharp/System/Console/BackgroundColor/foregroundcolor3.cs Converts outputs to interpolation and normalizes loop formatting.
snippets/csharp/System/Console/BackgroundColor/Example2.cs Normalizes indentation and brace style.
snippets/csharp/System/Console/BackgroundColor/backgroundcolor1.cs Normalizes indentation, uses new string(...), and modernizes spacing.
snippets/csharp/System/CharEnumerator/Overview/CharEnumerator1.cs Normalizes formatting and converts one output to interpolation.
snippets/csharp/System/Char/TryParse/tp.cs Replaces framework type names with aliases and normalizes formatting.
snippets/csharp/System/Char/ToUpper/toupper5.cs Normalizes formatting and uses aliases/interpolated output.
snippets/csharp/System/Char/ToUpper/toupper1.cs Converts output to interpolation and uses aliases.
snippets/csharp/System/Char/ToString/tostring.cs Normalizes brace style and uses char alias.
snippets/csharp/System/Char/ToLower/tolower.cs Removes unused using and modernizes formatting/aliases.
snippets/csharp/System/Char/Parse/parse.cs Normalizes brace style and uses char alias for API call.
snippets/csharp/System/Char/Overview/textelements2a.cs Uses aliases and modern construction for StringInfo.
snippets/csharp/System/Char/Overview/textelements2.cs Uses aliases and modernizes ConvertFromUtf32 call.
snippets/csharp/System/Char/Overview/surrogate1.cs Uses target-typed new and char.ConvertFromUtf32.
snippets/csharp/System/Char/Overview/grapheme1.cs Uses target-typed new and modern array initialization syntax.
snippets/csharp/System/Char/Overview/GetUnicodeCategory3.cs Removes unused using and uses aliases/explicit foreach type.
snippets/csharp/System/Char/Overview/charstructure.cs Switches Char.* calls to char.* aliases where appropriate.
snippets/csharp/System/Char/IsWhiteSpace/iswhitespace.cs Normalizes brace style and uses char alias.
snippets/csharp/System/Char/IsSymbol/issymbol.cs Normalizes brace style and uses char alias.
snippets/csharp/System/Char/IsSurrogate/issurrogate.cs Normalizes brace style and uses char alias.
snippets/csharp/System/Char/IsSeparator/isseparator1.cs Modernizes aliases and loop formatting.
snippets/csharp/System/Char/IsSeparator/isseparator.cs Normalizes brace style and uses char alias.
snippets/csharp/System/Char/IsPunctuation/ispunctuation.cs Normalizes brace style and uses char alias.
snippets/csharp/System/Char/IsNumber/isnumber1.cs Converts to interpolation and normalizes method structure.
snippets/csharp/System/Char/IsNumber/isnumber.cs Normalizes brace style and uses char alias.
snippets/csharp/System/Char/IsLower/islower.cs Normalizes brace style and uses char alias.
snippets/csharp/System/Char/IsLetterOrDigit/isletterordigit.cs Normalizes brace style and uses char alias.
snippets/csharp/System/Char/IsLetter/isletter.cs Normalizes brace style and uses char alias.
snippets/csharp/System/Char/IsHighSurrogate/sur.cs Converts many outputs to interpolation and normalizes spacing/braces.
snippets/csharp/System/Char/IsDigit/isdigit.cs Normalizes brace style and uses char alias.
snippets/csharp/System/Char/IsControl/IsControl2.cs Converts composite formatting to interpolation and normalizes braces.
snippets/csharp/System/Char/IsControl/IsControl1.cs Converts output to interpolation and normalizes loop formatting.
snippets/csharp/System/Char/IsControl/iscontrol.cs Normalizes brace style and uses char alias.
snippets/csharp/System/Char/GetUnicodeCategory/getunicodecategory.cs Normalizes brace style and uses char alias.
snippets/csharp/System/Char/GetNumericValue/getnumericvalue1.cs Converts output to interpolation and normalizes method structure.
snippets/csharp/System/Char/GetNumericValue/getnumericvalue.cs Normalizes brace style and uses char alias.
snippets/csharp/System/Char/Equals/equals.cs Normalizes brace style and uses aliases.
snippets/csharp/System/Char/ConvertFromUtf32/utf.cs Converts many outputs to interpolation and modernizes API calls to char.*.
snippets/csharp/System/Char/CompareTo/compareto.cs Normalizes brace style and uses aliases.

Comment thread snippets/csharp/System/Console/Overview/setfont1.cs Outdated
Comment thread snippets/csharp/System/Char/IsSeparator/isseparator1.cs Outdated
Comment thread snippets/csharp/System/Console/Overview/example3.cs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants