Lets get started for making a .NET Core 2 Console Application. I feel like you have seen the new feature of asp.net core which are very important to see.
As i told you the prerequisites of .Net Core. Open your visual studio on windows go to new project and select .Net Core in left side of window and select Console App(.Net Core) in middle of the window.
Now you can see a window opened like program.cs the code for Hello World has came it is similar like we do in Asp.net simple console application.
using System; namespace ConsoleApp1 { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); } } }
Execute this code you will see a flash on the screen because we have not used code to stop the console application and display the message for this we will use Console.Read().
Console.Write("Press any key to continue..."); Console.ReadKey(true);
Now lets play with the console of .Net Core we will make application to take input as name and Print My name with Current date & time .
Console.WriteLine("\nWhat is your name? "); var name = Console.ReadLine(); var date = DateTime.Now; Console.WriteLine($"\nHello, {name}, on {date:d} at {date:t}!"); Console.Write("\nPress any key to exit..."); Console.ReadKey(true);
Finally, you can see the console application is very simple to learn and understand. Play and Enjoy with the code.