例如,如何将"x_req“颜色更改为洋红色,但不更改”请求“颜色?
如果需要,x_req是一个int变量。
string req_ = @"Requests: " + x_req;
string treq_ = @"Total Requests: " + x_treq;
string sucreq_ = @"Successful Requests: " + x_sucreq;
string errs_ = @"Errors: " + x_errs;
string time_ = @"Time elapsed: " + x_time + "s";
Console.WriteLine(req_);
Console.WriteLine(treq_);
Console.WriteLine(sucreq_);
Console.WriteLine(errs_);
Console.WriteLine(time_);发布于 2022-03-03 18:59:56
Console.Write("Requests: ");
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine(x_req);如果您不想强制使用新行,并在使用该颜色编写之前更改WriteLine,请使用Write而不是ForegroundColor。
https://stackoverflow.com/questions/71342250
复制相似问题