Hello World Program in C#
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace HelloWorld { class Program { static void Main(string[] args) { //Hello World Program// string name; Console.Write("Enter your name=>"); name = Console.ReadLine(); // store user name in name variable if (DateTime.Now.TimeOfDay.TotalHours >= 6 && DateTime.Now.TimeOfDay.TotalHours < 12)// using 24 hour 1-24 { Console.WriteLine("Good Morning " + name); Console.ReadLine(); } else if (DateTime.Now.TimeOfDay.TotalHours >= 12 && DateTime.Now.TimeOfDay.TotalHours < 16) { Console.WriteLine("GoodAfterNoon " + name); Console.ReadLine(); } else if (DateTime.Now.TimeOfDay.TotalHours >= 16 && DateTime.Now.TimeOfDay.TotalHours < 20) { Console.WriteLine("Good Evening " + name); Console.ReadLine(); } else { Console.WriteLine("Good Night " + name); Console.ReadLine(); } } } }
No comments:
Post a Comment