Beispiel #1
0
        static void Main(string[] args)
        {
            var      obj     = new COMDemo();
            IWelcome welcome = obj;

            Console.WriteLine(welcome.Greeting("John"));
            //
            IMath math = (IMath)obj;
            int   x    = math.Add(3, 5);

            Console.WriteLine(x);
            //释放内存
            Marshal.ReleaseComObject(math);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            COMDemo  obj     = new COMDemo();
            IWelcome welcome = obj;

            Console.WriteLine(welcome.Greeting("Stephanie"));

            IMath math;

            math = (IMath)welcome;
            int x = math.Add(4, 5);

            Console.WriteLine(x);
        }
Beispiel #3
0
        private static void Main()
        {
            var      obj     = new COMDemo();
            IWelcome welcome = obj;

            Console.WriteLine(welcome.Greeting("Stephanie"));

            obj.Completed += () => Console.WriteLine("Calculation completed");

            var math = (IMath)welcome;
            var x    = math.Add(4, 5);

            Console.WriteLine(x);

            Marshal.ReleaseComObject(math);
        }
Beispiel #4
0
        static void Main()
        {
            COMDemo  obj     = new COMDemo();
            IWelcome welcome = obj;

            Console.WriteLine(welcome.Greeting("Christian"));

            obj.Completed += () => Console.WriteLine("Calculation completed");
            //delegate
            //{
            //   Console.WriteLine("Calculation completed");
            //};

            IMath math;

            math = (IMath)welcome;
            int x = math.Add(4, 5);

            Console.WriteLine(x);

            Marshal.ReleaseComObject(math);
        }