Skip to content

Conversation

@developertemur
Copy link

I propose introducing short built-in aliases for common Console methods, such as:

writeln() → Console.WriteLine()
readln() → Console.ReadLine()
These would serve as convenience methods to improve code brevity, especially in top-level statements, quick utilities, teaching scenarios, or competitive programming.

Motivation
Typing Console.WriteLine and Console.ReadLine repeatedly is verbose, especially for short programs, demos, scripting, introductory programming, and REPL-like usage.

Other languages (Pascal's writeln, Kotlin’s println, Python’s input, etc.) provide concise ways to do this. C# could benefit from similar shorthand without changing semantics or removing the existing methods.

Example:

writeln("Enter your name:");
var name = readln();
writeln($"Hello, {name}");

Instead of:

Console.WriteLine("Enter your name:");
var name = Console.ReadLine();
Console.WriteLine($"Hello, {name}");

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Oct 20, 2025
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Oct 20, 2025
@stephentoub
Copy link
Member

Thanks for the PR. However, we do not except PRs adding new surface area unless that surface area has been reviewed and approved, following https://github.com/dotnet/runtime/blob/main/docs/project/api-review-process.md. Please feel free to open an issue.

@huoyaoyuan
Copy link
Member

If typing Console.XXX repeatedly is verbose, you can just add global using static System.Console;, then type WriteLine() directly. The added Modern class also needs to be imported as such.

The Convert methods aren't modern in any term - they are extremely legacy and very unlikely to be used.

@hamarb123
Copy link
Contributor

hamarb123 commented Oct 21, 2025

If anything is proposed, probably it should be proposed as a code snippet rather than an API, e.g.:
image

But note that there is already one for Console.WriteLine (cw):
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates that the PR has been added by a community member needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants