summaryrefslogtreecommitdiff
path: root/DSACore/Auxiliary/Extensions.cs
blob: 8ef6298ac736ad241a77384cbb85310f9dbbf3f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
namespace DSACore.Auxiliary
{
    public static class StringExtension
    {
        //This mehod extends string. It adds spaces until a fixed length is reached.
        //If the original string is already longer, it is returner unmodified.
        public static string AddSpaces(this string str, int length)
        {
            string temp = str;
        for(int i = str.Length; i < length; i++)
            {
                temp += " ";
            }
            return temp;
        }
    


        //This mehod extends string. 
        //It adds spaces at the HEAD of a string until a fixed length is reached.
        //If the original string is already longer, it is returner unmodified.
        public static string AddSpacesAtHead(this string str, int length)
        {
            string temp = "";
            for (int i = str.Length; i < length; i++)
            {
                temp += " ";
            }
            return temp + str;
        }
    }

}