Reference class along with their namespace - CSharp Custom Type

CSharp examples for Custom Type:namespace

Description

Reference class along with their namespace

Demo Code

class Program//from   w  ww  . j  av  a2  s .c  o  m
{
   static void Main(string[] args)
   {
      // Current date and time (using single statement)
      System.DateTime now = System.DateTime.Now;
      // Picking up individual components
      int day = now.Day;
      int month = now.Month;
      int year = now.Year;
      int hours = now.Hour;
      int minutes = now.Minute;
      int seconds = now.Second;
      System.DateTime justDateWithoutTime = now.Date;
      // Output
      System.Console.WriteLine("Day: " + day);
      System.Console.WriteLine("Month: " + month);
      System.Console.WriteLine("Year: " + year);
      System.Console.WriteLine("Hours: " + hours);
      System.Console.WriteLine("Minutes: " + minutes);
      System.Console.WriteLine("Seconds: " + seconds);
      System.Console.WriteLine("Date component: " + justDateWithoutTime);
      // Formatting output our way
      System.Console.WriteLine("Our output: " + year + ", " + month + "/" + day +      " " + hours + " hours " + minutes + " minutes");
   }
}

Result


Related Tutorials