简体   繁体   English

控制台应用程序中的System.Drawing.Color

[英]System.Drawing.Color in console application

Simple question from .NET beginner. 来自.NET初学者的简单问题。 How to work with colors in console application? 如何在控制台应用程序中使用颜色? VS do not let me declarate System.Drawing.Color namespace. VS不要让我声明System.Drawing.Color命名空间。 I need to assign color for one method in console application. 我需要为控制台应用程序中的一个方法指定颜色。

Regards, Tomas 此致,托马斯

All you need to do is add a reference to System.Drawing.dll . 您需要做的就是添加对System.Drawing.dll的引用。 This isn't included by default in a console app, but you can add it without any issues. 默认情况下,这不包含在控制台应用程序中,但您可以毫无问题地添加它。

This is actually very simple, for example: 这实际上非常简单,例如:

Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Yellow");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM