Example #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Extension Methods *****\n");

            #region Display defining assembly extension
            // The int has assumed a new identity!
            int myInt = 12345678;
            myInt.DisplayDefiningAssembly();

            // So does this DataSet!
            System.Data.DataSet d = new System.Data.DataSet();
            d.DisplayDefiningAssembly();

            // And this MediaPlayer!
            System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
            sp.DisplayDefiningAssembly();

            // Remember!  Extension methods can be called as normal static
            // methods.
            MyExtensions.DisplayDefiningAssembly(false);
            #endregion

            #region New integer functionality
            // Use new integer functionality.
            Console.WriteLine("Value of myInt: {0}", myInt);
            Console.WriteLine("Reversed digits of myInt: {0}", myInt.ReverseDigits());
            myInt.Foo();
            myInt.Foo("Ints that Foo?  Who would have thought it!");
            #endregion

            UseCar();
            Console.ReadLine();
        }
Example #2
0
        public static void Demonstrate()
        {
            var myInt = 100;
            myInt.DisplayDefiningAssembly();

            var ds = new System.Data.DataSet();
            ds.DisplayDefiningAssembly();
        }
Example #3
0
        public static void TestExtension()
        {
            int myInt = 12345678;

            myInt.DisplayDefiningAssembly();
            System.Data.DataSet d = new System.Data.DataSet();
            d.DisplayDefiningAssembly();
            Console.ReadLine();
        }
Example #4
0
        static void Main(string[] args)
        {
            int i = 12345;

            i.DisplayDefiningAssembly();

            System.Data.DataSet d = new System.Data.DataSet();
            d.DisplayDefiningAssembly();

            Console.WriteLine(i.ReverseDigits());
        }
Example #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Funn with Extension Methods\n");
            int myInt = 12345678;

            myInt.DisplayDefiningAssembly();

            System.Data.DataSet d = new System.Data.DataSet();
            d.DisplayDefiningAssembly();

            System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
            sp.DisplayDefiningAssembly();

            Console.WriteLine("Value of myInt: {0}", myInt);
            Console.WriteLine("Reversed digits pf myInt: {0}", myInt.ReverseDigits());
        }
Example #6
0
        static void Main(string[] args)
        {
            int myInt = 123456789;

            myInt.DisplayDefiningAssembly();
            Console.WriteLine(myInt.ReverseDigits());

            var dataSet = new System.Data.DataSet();

            dataSet.DisplayDefiningAssembly();

            var personel  = new Personel("Sinan");
            var personels = new PersonelList();

            personels.Add(personel);
            personels.CallExtensionMethod();
        }
        public static void Main(string[] args)
        {
            int myInt = 1234567;

            myInt.DisplayDefiningAssembly();

            System.Data.DataSet d = new System.Data.DataSet();
            d.DisplayDefiningAssembly();

            System.Media.SoundPlayer player = new System.Media.SoundPlayer();
            player.DisplayDefiningAssembly();

            int rev = myInt.ReverseDigits();

            Console.WriteLine(rev);
            Console.ReadKey();
        }
Example #8
0
        static void InvokingExtension()
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("=> Invoking Extension Methods");

            int myInt = 12345678;

            myInt.DisplayDefiningAssembly();

            System.Data.DataSet d = new System.Data.DataSet();
            d.DisplayDefiningAssembly();

            System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
            sp.DisplayDefiningAssembly();

            Console.WriteLine($"Reversed digits of {myInt} is {myInt.ReverseDigits()}");
        }
Example #9
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Extension Methods *****\n");
            // The int has assumed a new identity!
            int myInt = 12345678;

            myInt.DisplayDefiningAssembly();
            // So has the DataSet!
            System.Data.DataSet d = new System.Data.DataSet();
            d.DisplayDefiningAssembly();
            // And the SoundPlayer!
            System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
            sp.DisplayDefiningAssembly();
            Console.WriteLine("Value of myInt: {0}", myInt);
            Console.WriteLine("Reversed digits of myInt: {0}", myInt.ReverseDigits());
            Console.ReadLine();
        }
Example #10
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Extension Methods *****\n");

            int myInt = 12345678;

            myInt.DisplayDefiningAssembly();

            System.Data.DataSet d = new System.Data.DataSet();
            d.DisplayDefiningAssembly();

            // Use new integer functionality
            Console.WriteLine("Value of myInt: {0}", myInt);
            Console.WriteLine("Reversed digits of myInt: {0}", myInt.ReverseDigits());

            Console.ReadLine();
        }
Example #11
0
 static void Main(string[] args)
 {
     Console.WriteLine("***** Fun with Extension Methods *****\n");
     // The int has assumed a new identity!
     int myInt = 12345678;
     myInt.DisplayDefiningAssembly();
     // So has the DataSet!
     System.Data.DataSet d = new System.Data.DataSet();
     d.DisplayDefiningAssembly();
     // And the SoundPlayer!
     System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
     sp.DisplayDefiningAssembly();
     // Use new integer functionality.
     Console.WriteLine("Value of myInt: {0}", myInt);
     Console.WriteLine("Reversed digits of myInt: {0}", myInt.ReverseDigits());
     Console.ReadLine();
 }
Example #12
0
        static void Main(string[] args)
        {
            Console.WriteLine("**** Fun with Extension Method****");

            int myInt = 12345678;

            myInt.DisplayDefiningAssembly();

            System.Data.DataSet d = new System.Data.DataSet();
            d.DisplayDefiningAssembly();

            System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
            sp.DisplayDefiningAssembly();

            Console.WriteLine($"Value of myInt: {myInt}");
            Console.WriteLine($"Reversed digits of myInt: {myInt.ReverseDigit()}");

            Console.Read();
        }
Example #13
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Fun with extensions");

            // the int has new superpowers
            int myI = 123456789;

            myI.DisplayDefiningAssembly();
            Console.WriteLine("Int only powers: I = {0}; Reversed = {1}", myI.ReverseDigits(), myI.ToString());

            // new DataSet powers...
            System.Data.DataSet d = new System.Data.DataSet();
            d.DisplayDefiningAssembly();

            // and SoubdPlayer...
            System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
            sp.DisplayDefiningAssembly();

            Console.ReadLine();
        }
Example #14
0
        private static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Extension Methods *****\n");
            const int myInt = 12345678;

            myInt.DisplayDefiningAssembly();

            var d = new System.Data.DataSet();

            d.DisplayDefiningAssembly();

            var sp = new System.Media.SoundPlayer();

            sp.DisplayDefiningAssembly();

            Console.WriteLine("Value of myInt: {0}", myInt);
            Console.WriteLine("Reversed digits of myInt: {0}", myInt.ReverseDigits());

            Console.ReadLine();
        }
Example #15
0
        public static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Extension Methods *****\n");
            int myInt = 123456;

            //MyExtensions.DisplayDefiningAssembly(myInt);
            Console.WriteLine(myInt.ReverseDigits().ToString());
            myInt.DisplayDefiningAssembly();
            Console.ReadKey();

            // To же и в DataSet!
            System.Data.DataSet d = new System.Data.DataSet();
            d.DisplayDefiningAssembly();
            Console.ReadKey();

            //Ив SoundPlayer!
            System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
            sp.DisplayDefiningAssembly();
            Console.ReadKey();
        }
Example #16
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with extension methods *****\n");

            // This int has assumed a new identity!
            int myInt = 12345678;

            myInt.DisplayDefiningAssembly();

            // So has the data set!
            System.Data.DataSet d = new System.Data.DataSet();
            d.DisplayDefiningAssembly();

            // And the soundplayer!
            System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
            sp.DisplayDefiningAssembly();

            // Use new integer functionality.
            Console.WriteLine("Value of myInt: {0}", myInt.ReverseDigits());

            Console.ReadLine();
        }
Example #17
0
        static void FuckWithExtensionMethods()
        {
            System.Console.WriteLine("=> fun with extension methods:");

            int myInt = 1234567890;

            myInt.DisplayDefiningAssembly();

            // so has the DataSet
            System.Data.DataSet d = new System.Data.DataSet();
            d.DisplayDefiningAssembly();

            // and the SoundPlayer
            System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
            sp.DisplayDefiningAssembly();

            // use new integer functinoality
            System.Console.WriteLine("value of myInt: {0}", myInt);
            System.Console.WriteLine("reversed digits of myInt: {0}", myInt.ReverseDigits());

            Console.ReadLine();
        }
Example #18
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Extension Methods *****");

            //  本整形表示一个新的身份标识
            int myInt = 12345678;

            myInt.DisplayDefiningAssembly();

            //  下面是DataSet
            System.Data.DataSet d = new System.Data.DataSet();
            d.DisplayDefiningAssembly();

            //  下面是SoundPlayer
            System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
            sp.DisplayDefiningAssembly();

            //  使用整形的新功能
            Console.WriteLine("Value of myInt: {0}", myInt);
            Console.WriteLine("Reversed digits of myInt: {0}", myInt.ReverseDigits());

            Console.ReadLine();
        }
Example #19
0
        /// <summary>
        /// Invoking Extension Method
        /// </summary>
        private void InvokingExtensionMethod()
        {
            Console.WriteLine("=> Invoking Extension Method: ");

            // The int has assumed a new identity
            int myInt = 12345678;

            myInt.DisplayDefiningAssembly();

            // So has the DataSet
            System.Data.DataSet d = new System.Data.DataSet();
            d.DisplayDefiningAssembly();

            // And the SoundPlayer
            System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
            sp.DisplayDefiningAssembly();

            // Use new integer functionality
            Console.WriteLine("Value of mInt: {0}", myInt);
            Console.WriteLine("Reversed digits of myInt: {0}", myInt.ReverseDigits());

            Console.WriteLine();
        }