How to use PadLeft() with string array in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] arr = { "c#", "1", "c++", "2", "java", "3" };

            foreach (string s in arr) 
                Console.WriteLine(s.PadLeft(7, '.'));
        }
    }
}


/*
run:
    
.....c#
......1
....c++
......2
...java
......3

*/

 



answered Feb 12, 2017 by avibootz

Related questions

1 answer 234 views
1 answer 162 views
162 views asked Feb 11, 2017 by avibootz
1 answer 103 views
2 answers 280 views
280 views asked Aug 4, 2018 by avibootz
...