Advertisement
Guest User

chakrit

a guest
Jan 18th, 2009
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1.  
  2. using System;
  3.  
  4. static class Program
  5. {
  6.     static void Main()
  7.     {
  8.         // all three print the same time
  9.  
  10.         Field.FieldA.DoSomething();
  11.  
  12.         for (int i = 0; i < 1000; i++) /*waste time */ ;
  13.         Field.FieldA.FieldA.DoSomething();
  14.  
  15.         for (int i = 0; i < 1000; i++) /*waste time */ ;
  16.         Field.FieldA.FieldA.FieldA.DoSomething();
  17.  
  18.         Console.ReadKey();
  19.     }
  20.  
  21.     class Field
  22.     {
  23.         public class FieldA : Field
  24.         {
  25.             private static DateTime _time;
  26.  
  27.             static FieldA() { _time = DateTime.Now; }
  28.  
  29.             public static void DoSomething() { Console.WriteLine(_time.ToLongTimeString()); }
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement