DllImport, Kernel32.dll

I wanted to understand how the static methods of the Console class work, and I wanted to write my own WriteLine method. I read a lot of topics and lessons on this topic, I kind of understood the essence.

using static System.Console;
using System.Runtime.InteropServices;


namespace ConsoleApp1
{
    class Program
    {
        private const uint STD_INPUT_HANDLE = 0xfffffff6;
        [DllImport("kernel32.dll")]
        private static extern int GetStdHandle(uint nStdHandle);
        [DllImport("kernel32.dll", SetLastError = true)]
        static extern int WriteConsoleA(int hConsoleOutput, object lpBuffer, int nNumberOfCharsToWrite, ref int lpNumberOfCharsWritten, object lpReserved);


        static void Main()
        {
            WriteLineC("a");
        }

        public static void WriteLineC(string s)
        {
            int len = 0;
            WriteConsoleA(GetStdHandle(STD_INPUT_HANDLE), s + "\n", s.Length + 2, ref len, 0);
        }
    }
}

However, when you start the program, nothing happens, it ends quietly. I can't figure it out any further. Does anyone know how the Write, Read methods work in the Console class? Thank you in advance.

Author: MRamsey, 2020-05-03