IJUL'S BLOG

Menampilkan Waktu sekarang C#

g usah buang - buang tenaga buat bikin algoritma nampilin waktu saat ini,,,,lgsg aja ni code nya;


namespace ConsoleApplication1
{
   public class Time {

           // private member variables

           int Year;

           int Month;

           int Date;

           int Hour;

           int Minute;

           int Second;

 

           // constructor

           public Time(System.DateTime dt) {

               Year = dt.Year;

               Month = dt.Month;

               Date = dt.Day;

              Hour = dt.Hour;

             Minute = dt.Minute;

             Second = dt.Second;

         }

 

         // public methods

         public void DisplayCurrentTime() {

             System.Console.WriteLine("\n\n\t\t\t\t{0}/{1}/{2} {3}:{4}:{5}",

               Month, Date, Year, Hour, Minute, Second);
             Console.Read();

         }

       
     }

 
    class LatKonstruktor {

         public static void Main(string[] args) {

             DateTime currTime = DateTime.Now;

            Time t = new Time(currTime); //memanggil constructor
             t.DisplayCurrentTime();

         }

     }
    }

1 komentar:

B.B.B mengatakan...

tq bos :D

Posting Komentar

Powered By Blogger
Diberdayakan oleh Blogger.

Entri Populer

PENGUNJUNG

Buku Tamu

About Me

Foto Saya
Ijal Ferdi
there is no something special about me,,, but this blog is so special for me......
View my complete profile

Total Tayangan Halaman

Followers