using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FieldsAndConstructors
{
    class Examples19_20
    {
        // Listing 3-19
        public class Bar
        {
            private static DateTime _firstUsed;
            static Bar()
            {
                Console.WriteLine("Statyczny konstruktor klasy Bar");
                _firstUsed = DateTime.Now;
            }
        }

        public static void StaticConstruction()
        {
            Bar b = new Bar(); // Owszem, to konstruktor instancji, ale wywołuje konstruktor statyczny.
        }

        // Listing 3-20
        private static int a = b + 1;
        private static int b = 41;
        private static int c = b + 1;

        public static void StaticInitializerOrdering()
        {
            Console.WriteLine(a);
            Console.WriteLine(b);
            Console.WriteLine(c);
        }
    }
}
