I would expect an error during run time, but the code works?

using System;

namespace ArraysAndLists_Excercise_2
{
class Program
{
static void Main(string args)
{
string inputName;
string outputName;
char lijst = new char[1];

        Console.Write("Geef uw naam: ");
        inputName = Console.ReadLine();

        lijst = inputName.ToCharArray();
        Array.Reverse(lijst);
        outputName = new string(lijst);
                    
        Console.WriteLine("InputName is: {0}",inputName);
        Console.WriteLine("OutputName is: {0}", outputName);

    }
}

}
I’ve created an array of char, which normally may only contain one (1) character. But when I run the program and I enter multiple characters, then the program doesn’t stop. It just works normally. I would like to know why I can put more than one charachter in the ‘lijst’ array and why the program doesn’t stop when I enter multiple characters?

The array you create with new char[1] contains only one character, yes. But with lijst = inputName.ToCharArray() you assign a different array to your lijst variable - the one returned by inputName.ToCharArray().

Sam, thanks for your reply!