How to create a Simple “Hello Kitty” with C# (Console Application)
First we create a “Console-Application-Project” within the Visual C# Express Studio
The Console Project Name can be anything you like (ex. HelloKitty)
After pressing “ok” the File Program.cs will be opened.
It will look something like this:
With the codeline: System.Console. you can work with the console “window”, display data, read data, etc.
To Display a normal text you use the function “WriteLine”, which writes a line of text. If you want to write just one character, you can use “Write” instead.
System.Console.WriteLine("Hello Kitty");
If you compile the program, the console window will be closed instantaneous, to prevent this behavior, we wait till the user enters at least one character.
This can be achvieved with the functions “ReadKey”, “Read” or “ReadLine”. The difference between those functions is that “ReadKey”, reads exactly one character and displays this character on the console, “Read” reads just the next character and “ReadLine” reads the whole line on the console application.
System.Console.ReadKey();
It should look like this now:
using System; using System.Text; namespace HelloKitty { class Program { static void Main(string[] args) { System.Console.WriteLine("Hello Kitty"); System.Console.ReadKey(); } } }
After compiling the program, it should open a console window and display the text which has been entered after the “WriteLine” command: