keronfollow.blogg.se

Iconsole application examples
Iconsole application examples








iconsole application examples

  • Console.ReadLine: Reads the next line of characters from the standard input stream.
  • iconsole application examples

    Console.Read: Reads the next character from the standard input stream.When we want to read user’s data in C# in Console application, we can use Console.Readline() or Console.Read() method of C#.īasically, the difference between Console.ReadLine() and Console.Read() is You will also notice that while loop keeps on running, means you will see the output on console, until you click “Enter” on your keyboard as Console.ReadKey().Key is looking for Console.Enter Key to end this while loop. In the above example, in the above example, we are using both the methods Console.WriteLine() and Console.Write(), when using Console.WriteLine(), we are printing current date and time and cursor is moved to a new line, then using Console.Write() to print “Press to exit…” which keeps the cursor in the same line. While (Console.ReadKey().Key != ConsoleKey.Enter)

    iconsole application examples

    prints text but keeps cursor in same line print current date and time and moves cursor to next lineĬonsole.WriteLine("Current Date and time is : "+dat) Let’s take a look at an example: using System SEE ALSO: Programming with Beef: Open source language takes inspiration from C# Only difference between Console.WriteLine() and Console.Write() is that, Console.WriteLine() also makes control move to the next line while Console.Write() keeps the Control in same line. In C# you can write or print to console using Console.WriteLine() or Console.Write(), basically both methods are used to print output of console. If you have just started learning C#, you might be interested to know, how we can read or write to console app using C#, in this article, I have explained it with an example.










    Iconsole application examples