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 161 views
161 views asked Feb 11, 2017 by avibootz
1 answer 129 views
129 views asked Feb 12, 2017 by avibootz
2 answers 224 views
1 answer 100 views
1 answer 103 views
1 answer 173 views
1 answer 107 views
107 views asked Jul 23, 2020 by avibootz
...