display format for results in console
<p>I am trying to display my results as follows:</p>

<pre><code>-.-|-    [tab]  kt   
-.|--    [tab]  nm  
-.|-|-   [tab]  ntt
</code></pre>

<p>But this is my current output</p>

<pre><code>-.-|-|  kt  
-.|--|  nm  
-.|-|-|  [tab]ntt
</code></pre>

<p>There is a <code>|</code> at the end of every Morse code which I would like to remove since it is at the end. </p>

<p>Also because the user can input Morse code with space between dots and dashes -  i noticed that it affects the alignment of the characters and not all of them get tabbed properly. The word tab isn't supposed to show i just wrote it in because I didn't know how to place a real tab.</p>

<pre><code>private static readonly IDictionary&lt;char, string&gt; morseCode_alpha = new Dictionary&lt;char, string&gt;
{
    {'a', ".-"},{'b',"-..."}, {'c',"-.-."}, {'d',"-.."}, {'e',"."},
    {'f',"..-."}, {'g',"--."}, {'h',"...."},{'i',".."}, {'j',".---"}, 
    {'k',"-.-"}, {'l',".-.."}, {'m',"--"}, {'n',"-."}, {'o',"---"}, 
    {'p',".--."}, {'q',"--.-"}, {'r',".-."}, {'s',"..."}, {'t',"-"}, 
    {'u',"..-"}, {'v',"...-"}, {'w',".--"}, {'x',"-..-"}, {'y',"-.--"}, {'z',"--.."}
};

private static string ConvertMorseToText(string symbolCode)
{
    var builder = new StringBuilder(4 * symbolCode.Length);

    foreach (char c in symbolCode)
        builder.Append(morseCode_alpha[c]);
    return builder.ToString();
}

private static string ConvertTextToMorse(char ch)
{
    if (morseCode_alpha.Keys.Contains(ch))
        return morseCode_alpha[ch];
    else
        return string.Empty;
}

private static string ConvertStringToMorse(string letters)
{
    StringBuilder sb = new StringBuilder();
    foreach (char ch in letters)
    {
        if (sb.Length != 0 &amp;&amp; sb[sb.Length - 1] != ' ')
            sb.Append("|");
        sb.Append(ConvertTextToMorse(ch));
    }
    return sb.ToString();
}

private static IEnumerable&lt;string&gt; Permutations( string symbolCode)
{
    int n = symbolCode.Length;
    if (n == 0 || symbolCode.Length == 0)
        yield return " ";
    else
        foreach (var entry in morseCode_alpha)
            if (symbolCode.StartsWith(entry.Value))
                foreach (string next in Permutations(symbolCode.Substring(entry.Value.Length)))
                    yield return entry.Key + next;
}

private static void Write( string rest)
{
    string result = ConvertStringToMorse(rest);
    Console.Write(result+"\t");
    Console.WriteLine(rest);
}

static void Main(string[] args)
{
    string morseInput;
    string entered = "";
    do
    {
        Console.WriteLine("Enter Morse Code: \n");
        morseInput = Console.ReadLine().Replace(" ","");
        bool isValid = Regex.IsMatch(morseInput, @"^[-.]+$");
        if (isValid)
        {
            Console.WriteLine("\nAll permutations:\n");
            string morse = ConvertMorseToText(entered);
            string permutations = morseInput.Substring(morse.Length);
            Write(permutations);
            var nexts = new List&lt;string&gt;(Permutations(permutations));
            foreach (string next in nexts)
                Write(next);
        }
        else
        {
            Console.WriteLine("\nFormat of morse must be only dots and dashes.");
            Console.WriteLine("Parameter name: "+morseInput+"\n");
        }
    }
    while (morseInput.Length != 0);
}
</code></pre>
