C#。改变一个句子中的一个字符颜色
C#. Change one character color in a sentence
如何更改字符的颜色?我想让A和B和C变成蓝色。
Console.Write("Choose between, A or B or C : ");
我在网上找到的唯一方法是Console.ForegroundColor = ConsoleColor.Blue
,但我只需要A B C是蓝色的,而不是整个句子。
设置颜色,然后用该颜色写下你想要的颜色,然后重置颜色,然后用最近的颜色写下你想要的颜色。
ConsoleColor recentForegroundColor = Console.ForegroundColor;
Console.Write("Choose between, ");
Console.ForegroundColor = ConsoleColor.Blue;
Console.Write("A");
Console.ForegroundColor = recentForegroundColor;
Console.Write(" or ");
Console.ForegroundColor = ConsoleColor.Blue;
Console.Write("B");
Console.ForegroundColor = recentForegroundColor;
Console.Write(" or ");
Console.ForegroundColor = ConsoleColor.Blue;
Console.Write("C");
Console.ForegroundColor = recentForegroundColor;
Console.Write(" : ");
如何更改字符的颜色?我想让A和B和C变成蓝色。
Console.Write("Choose between, A or B or C : ");
我在网上找到的唯一方法是Console.ForegroundColor = ConsoleColor.Blue
,但我只需要A B C是蓝色的,而不是整个句子。
设置颜色,然后用该颜色写下你想要的颜色,然后重置颜色,然后用最近的颜色写下你想要的颜色。
ConsoleColor recentForegroundColor = Console.ForegroundColor;
Console.Write("Choose between, ");
Console.ForegroundColor = ConsoleColor.Blue;
Console.Write("A");
Console.ForegroundColor = recentForegroundColor;
Console.Write(" or ");
Console.ForegroundColor = ConsoleColor.Blue;
Console.Write("B");
Console.ForegroundColor = recentForegroundColor;
Console.Write(" or ");
Console.ForegroundColor = ConsoleColor.Blue;
Console.Write("C");
Console.ForegroundColor = recentForegroundColor;
Console.Write(" : ");