How to use PadRight() and 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 = new string[]
            {
                "c#",
                "c",
                "c++",
                "java",
                "python"
            };

            foreach (string s in arr)
            {
                Console.Write("yes".PadRight(10));
                Console.WriteLine(s.PadLeft(8));
            }
        }
    }
}


/*
run:
    
yes             c#
yes              c
yes            c++
yes           java
yes         python

*/

 



answered Feb 11, 2017 by avibootz

Related questions

1 answer 150 views
150 views asked Feb 11, 2017 by avibootz
1 answer 119 views
119 views asked Feb 12, 2017 by avibootz
2 answers 210 views
1 answer 93 views
1 answer 95 views
1 answer 159 views
1 answer 96 views
96 views asked Jul 23, 2020 by avibootz
...