How can I align text in columns using Console.WriteLine?

前端 未结 8 1242
隐瞒了意图╮
隐瞒了意图╮ 2020-11-28 22:11

I have a sort of column display, but the end two column\'s seem to not be aligning correctly. This is the code I have at the moment:

Console.WriteLine(\"Cust         


        
8条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 22:54

    Do some padding, i.e.

              public static void prn(string fname, string fvalue)
                {
                    string outstring = fname.PadRight(20)  +"\t\t  " + fvalue;
                    Console.WriteLine(outstring);
    
                }
    
    

    This worked well, at least for me.

提交回复
热议问题