V
V
vovkaooo12017-04-26 13:48:57
css
vovkaooo1, 2017-04-26 13:48:57

Is it possible in a c# console command to change the color of characters in a string?

Hello, I know that it is possible to change text color and color by text in the console.
Is it possible to change the background from black to another color.
And the main question.
There is a string
string stroka = "new sausage la la la.."; Can I change the color of only "la la" in this line, and leave everything else white? or I have only one way out - is to divide the string by certain characters and only then change the color of the line where this word is located?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
A
Alexander, 2018-05-23
@bulatah972

As an option to set

img { 
    display: block;
    margin: 0;
    padding: 0;
}

I
inkShio, 2018-05-23
@inkShio

Few info. What you posted means nothing. Maybe the image has an indent, or maybe something else.

R
Roman Musalimov, 2018-05-23
@mQExcellent

I think that .portfolio-items should be wrapped in a container and given the following parameters:

<div class="container">
   <div class="portfolio-items">
       <div class="portfolio-item"><img src="img/portfolio-item-1.jpg" alt="#"></div>
       <div class="portfolio-item"><img src="img/portfolio-item-2.jpg" alt="#"></div>
   </div>
</div>

.container {
  max-width: 1280px;
  margin: 0 auto;
}

.portfolio-items{
  display: flex;
  margin: 0;
  padding: 0;
  transition: 0.3s ease-in-out;
}

Try this, it should help

A
Alexander Storozhuk, 2017-04-27
@vovkaooo1

If you need to paint the entire console with one color - use

Console.BackgroundColor = ConsoleColor.Green;   // к примеру зеленый
Console.Clear();

But in this case, all the text displayed in the console will be lost.
You can't line up by color. You can only break it into parts, each of which should be displayed in its own color.
Something like this in your case
Console.Write("новая колбаса ");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("ла ла ");
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("ла..");

A
Alexander Ter, 2017-04-26
@alexsandr0000

Here is an example

Console.ForegroundColor = ConsoleColor.Red;
Console.BackgroundColor = ConsoleColor.Yellow;
Console.WriteLine("Вычисления c и s круга");
Console.WriteLine("");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.BackgroundColor = ConsoleColor.Black;
Console.Write("Введите радиус > ");
double r = Convert.ToDouble(Console.ReadLine());
//длина окружности:
double c = 2 * Math.PI * r;
//площадь круга:
double s = Math.PI * r * r;
//округляем значения:
c = Math.Round(c, 2);
s = Math.Round(s, 2);
//печатаем результаты вычислений в консольном окне:
Console.ForegroundColor = ConsoleColor.Green;

O
Ogoun Er, 2018-07-20
@Ogoun

Everything is already written

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question