Caesar Cipher Extension Exercise

I am working on the Caesar Cipher project and trying to complete Step 14 where you tell the loop to skip symbols so that they do not get encrypted, but are included when you print to the console

I found this thread which asked a similar question, however, when I used the solution recommended, it would print line a line for each character; adding one character each time (see attached screenshot). Any help is appreciated

Might be overdue, I had the same issue and if I remeber correctly on how I solved it, it had to do with the last part of the code;

string encrypted = String.Join("", encryptedMessage);
Console.WriteLine($“You encoded message is: \n{encrypted}”);

Being written inside the for loop and not out side the loop (still this code has to be inside the static void main), since the loop, loopes each char everytime, hence displaying what you posted and not a whole string. Hope this helps!

So the code should be;
static void Main(string args)

{

  char[] alphabet = new char[] {'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'};

  

  Console.WriteLine("Write a message to encrypt: ");

  string message = Console.ReadLine();

  string lower = message.ToLower();

  char[] secretMessage = lower.ToCharArray();

  char[] encryptedMessage = new char[secretMessage.Length];

  for (int i = 0; i < secretMessage.Length; i++)

    {

      char letter = secretMessage[i];

        if (Array.IndexOf(alphabet,letter)!=-1)

          {

            int newLetterPos = ((Array.IndexOf(alphabet,letter))+3)%alphabet.Length;

            encryptedMessage [i] = alphabet[newLetterPos];

         }

    }

      string encrypted = String.Join("", encryptedMessage);

      Console.WriteLine($"You encoded message is: \n{encrypted}");

}