// Use this for initialization
    void Start()
    {
        myLoader         = new ConstructorExample(0.123f, "Hi");
        myLoader.manager = this;

        print(myLoader.name);

        print(this);
    }
Пример #2
0
        static void Main(string[] args)
        {
            int    i = 123;
            object o = i;

            //Console.WriteLine(o is object);

            o = 2;

            //Console.WriteLine(o);

            // Will log true and 2, because we've boxed i and is now a reference type, so it was changed to 2.

            o = 123;
            i = (int)o;

            //Console.WriteLine(i is int);

            i = 3;
            int a = i;

            a = 20;

            //Console.WriteLine(i);

            // Will log true and 3. We've unboxed i and is now a value type.

            // int a has another location in the memory, so int i stays the same.

            double decimalNum = 5.55;
            bool   isTrue     = true;
            string str        = "string";

            Sum(i, decimalNum, str);

            CreateClassPoint();
            CreatePoint();


            Console.WriteLine(ConstructorExample.unInitVar);
            ConstructorExample constructorExample = new ConstructorExample();

            Console.WriteLine(ConstructorExample.unInitVar);

            // first, it will initialize the variable in the static constructor.
            // after we've called the ConstructorExample the second time, the variable will initialize in the public constructor.
        }
Пример #3
0
        public void TestConstructorDependencyOutput()
        {
            IExample obj = new ConstructorExample(new Dependency1());

            Assert.AreEqual("Elaborated by " + typeof(Dependency1), obj.DoSomething());
        }
Пример #4
0
 public static void Main(string[] args)
 {
     ConstructorExample c1 = new ConstructorExample();
     ConstructorExample c2 = new ConstructorExample();
 }