Home > Net >  C # console alignment problem
C # console alignment problem

Time:02-11

Think excuse me, I set it every number is \ t to alignment, there will be a few more smaller column spacing between
?


CodePudding user response:

Try to string format to align: ToString (" 00 ")

CodePudding user response:

 using System; 
Using System. Linq;

The namespace ConsoleApp1
{
Class Program
{
The static void Main (string [] args)
{
Var RND=new Random ();
Enumerable. Range (1, 10). ToList (). The ForEach (I=& gt;
{
Enumerable. Range (1, 10). ToList (). The ForEach (j=& gt;
{
The Console. Write (${" RND. Next (2, 3), 8} ");
});
Console. WriteLine ();
});
}
}
}

CodePudding user response:

reference 1/f, the wise know already should good karma response:
try to string format to align:. ToString () "00"


Is written as follows, also can appear abnormal alignment, unknown so

String strAA="";
For (int I=0; I & lt; 200; I++)
{
StrAA=strAA + "\ t" + i.T oString ();
}
Console. WriteLine (strAA. ToString ());

CodePudding user response:

Output \ t. (TAB) you give up control of the format you should use a String object PadLeft method to finely control leading Spaces
  •  Tags:  
  • C#
  • Related