Пример #1
0
        unsafe static void Main(string[] args)
        {
            foreach (string arg in args)
            {
                Console.WriteLine(arg);
            }

            var p = new Program();

            myDelegate  = new MyDelegate(p.MyDelegateCallback);
            myDelegate += p.MyDelegateCallback;

            //myDelegate = new MyDelegate(MyDelegateCallbackStatic);
            myDelegate += MyDelegateCallbackStatic;
            myDelegate -= MyDelegateCallbackStatic;
            //myDelegate = MyDelegateCallbackStatic + myDelegate;
            myDelegate = myDelegate + MyDelegateCallbackStatic;
            //myDelegate = (MyDelegate)Delegate.RemoveAll(myDelegate, new MyDelegate(MyDelegateCallback));
            if (myDelegate != null)
            {
                myDelegate("Invoke");
            }

            value  = "lll";
            myEnum = MyEnum.A;

            var m = new MyBaseClass();

            m.MyVirtMethod();
            var m2 = (MyAbstractClass)m;

            m2.MyVirtMethod();
            m.MyFoo();
            //return;

            //Console.WriteLine("Hello World!");
            //Console.WriteLine("Hello World!2");
            //return;

            //string value = typeof(int).ToString();
            //Console.WriteLine(value);

            //Program.MyAutoPropStatic = 0;
            //var v = "Hello World!";
            //v = MyAutoPropStatic.ToString();
            ////v = myEnum.ToString();// TODO
            //v = GetValue(v.GetType().ToString());
            //Console.WriteLine("Hello World!" + value);

            //foreach (var i in "asdfas")// requires method System.String::get_Chars(int32)
            var a = new int[5] {
                1, 2, 3, 4, 5
            };

            if (a.GetType() == typeof(int[]))
            {
                Console.WriteLine(a.GetType().FullName);
            }
            //a[0] = new int[3];
            //int b = a.Length;
            //int c = a[0].Length;
            foreach (var aa in a)
            {
                Console.Write("^");
                if (aa == 88)
                {
                    break;
                }
            }

            i2 = new MyBaseClass()
            {
                b = 44,
                c = 33,
                d = 66
            };

            var i = new MyBaseClass()
            {
                b = 44,
                c = 33,
                d = 66
            };

            var a2 = stackalloc byte[3] {
                1, 2, 3
            };

            //         for (int i = 0, i2 = 0; i != a.Length && i2 != 4; ++i, i2 += 2)
            //{
            //	if (i == i2) Console.Write("*");
            //}

            //for (int i = 0; i != a.Length; ++i)
            //{
            //	Console.Write("$");
            //}

            var es = new MyEnumerable <int>();

            foreach (var e in es)
            {
                if (e == 0)
                {
                    Console.Write("T");
                }
            }
            float[] sldkfj;
            float[] sldkfj2;
            //MyG<short[]>[] myGArray;
            MyG <int> myG   = new MyG <int>();
            int       myGI  = myG.DoStuff();
            int       myGI2 = myG.DoStuff2 <int>(123);
            int       myGI3 = myG.DoStuff3 <int, float>(55f, 123, 55);
            var       myGIS = MyG <Vec3> .DoStuffStatic(true);

            Console.WriteLine(myG.GetType().FullName);
            try
            {
                MyAbstractClass c = new MyBaseClass();
                FooThrow((MyBaseClass)c);
            }
            catch (NotSupportedException e)
            {
                Console.WriteLine("NotSupportedException: " + e.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.Message);
            }
        }
Пример #2
0
        unsafe static void Main()        //string[] args)
        {
            //var m = new MyBaseClass();
            //m.MyVirtMethod();
            //var m2 = (MyAbstractClass)m;
            //m2.MyVirtMethod();
            //m.MyFoo();
            //return;

            //Console.WriteLine("Hello World!");
            //Console.WriteLine("Hello World!2");
            //return;

            //string value = typeof(int).ToString();
            //Console.WriteLine(value);

            //Program.MyAutoPropStatic = 0;
            //var v = "Hello World!";
            //v = MyAutoPropStatic.ToString();
            ////v = myEnum.ToString();// TODO
            //v = GetValue(v.GetType().ToString());
            //Console.WriteLine("Hello World!" + value);

            //foreach (var i in "asdfas")// requires method System.String::get_Chars(int32)
            var a = new int[5] {
                1, 2, 3, 4, 5
            };

            if (a.GetType() == typeof(int[]))
            {
                Console.WriteLine(a.GetType().FullName);
            }
            //a[0] = new int[3];
            //int b = a.Length;
            //int c = a[0].Length;
            foreach (var aa in a)
            {
                Console.Write("^");
                if (aa == 88)
                {
                    break;
                }
            }

            i2 = new MyBaseClass()
            {
                b = 44,
                c = 33,
                d = 66
            };

            var i = new MyBaseClass()
            {
                b = 44,
                c = 33,
                d = 66
            };

            var a2 = stackalloc byte[3] {
                1, 2, 3
            };

            //         for (int i = 0, i2 = 0; i != a.Length && i2 != 4; ++i, i2 += 2)
            //{
            //	if (i == i2) Console.Write("*");
            //}

            //for (int i = 0; i != a.Length; ++i)
            //{
            //	Console.Write("$");
            //}

            /*var es = new MyE();
             * foreach (var e in es)
             * {
             *
             * }*/
            float[] sldkfj;
            float[] sldkfj2;
            //MyG<short[]>[] myGArray;
            MyG <int> myG   = new MyG <int>();
            int       myGI  = myG.DoStuff();
            int       myGI2 = myG.DoStuff2 <int>(123);
            int       myGI3 = myG.DoStuff3 <int, float>(55f, 123, 55);
            var       myGIS = MyG <Vec3> .DoStuffStatic(true);

            Console.WriteLine(myG.GetType().FullName);
            try
            {
                FooThrow(new MyBaseClass());
                //FooThrow(null);// should be a compile time error
            }
            catch (NotSupportedException e)
            {
                Console.WriteLine("NotSupportedException: " + e.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }