Skip to content

[API Proposal]: Add overloads to Console.Write that also take a ConsoleColor parameter #61731

Closed

Description

@FilipToth

Background and motivation

This API proposal should just make it easier to write things of different colors to the console. Right now, we have to call three methods to do so. This is how we would do that now:

Console.ForegroundColor = ConsoleColor.Blue;
Console.Write("Hello!");
Console.ResetColor();

This is what I propose:

Console.Write(ConsoleColor.Blue, "Hello!");

This isn't anything critical, it's just some sugar to make writing code a little bit easier.

API Proposal

namespace System
{
    public static class Console
    {
        public void Write(ConsoleColor color, String value);
    }
}

I would suggest having an overload for Write and WriteLine.

API Usage

System.Console.WriteLine(ConsoleColor.Red, "Red text!");

Alternative Designs

No response

Risks

I do not see any risks associated with this.

Activity

  1. added
    api-suggestion
    on Nov 17, 2021
  2. ghost added
    untriaged
    on Nov 17, 2021
  3. removed
    untriaged
    on Nov 17, 2021
  4. adamsitnik commented on Nov 17, 2021

    @adamsitnik
    Member

    Hi @FilipToth

    Thank you for your proposal. I am going to include this in #52374 which we may include in .NET 7 if the stars align. It would most probably be exposed by the new Terminal type, with all the colors supported by VT100.

  5. added this to the Future milestone on Nov 17, 2021
  6. FilipToth commented on Nov 17, 2021

    @FilipToth
    ContributorAuthor

    Ok, Great that would be awesome. Thank you.

  7. stephentoub commented on Nov 17, 2021

    @stephentoub
    Member

    This is also a dup of #39746.

  8. adamsitnik commented on Nov 17, 2021

    @adamsitnik
    Member

    This is also a dup of #39746.

    I've not noticed that. In such a case I am going to close this issue.

    @FilipToth please follow #39746 and #52374 for updates. Thank you!

  9. ghost locked as resolved and limited conversation to collaborators on Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionarea-System.Console

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions