Introduciton
Printing message is usually our first task while learning a programming language. Just like anyother language C# also provides facility to print messages which is the most vital thing. Now just as C++, Java or Python, C# also has some built in libraries which provide different classes for different approaches. For printing a line we use System namespace which has Console class with function WriteLine().
Lets see an example
namespace HelloWorld { class Program { static void Main(string[] args) {//to print string we use Console.WriteLine(""); Console.WriteLine("Hello Codezila"); Console.WriteLine("Hello azuma"); //to wait for user to press enter to process further we use Console.ReadLine(); Console.ReadLine(); } } }
For further practice you can change the strings and print multiple strings at a time. Console.WriteLine() prints string in next line, to print strings in same line use Console.Write().
Beside Console.Write() you can also use concatenation.
Lets see an example
namespace PrintingWithConcatenation { class Program { static void Main(string[] args) { //to concatenate use + Console.WriteLine("hello" + " azuma"); Console.ReadLine(); } } }
For furthur queries click here
Comments
Post a Comment