Class1.cs
上传用户:lxycoco
上传日期:2022-07-21
资源大小:38457k
文件大小:1k
- using System;
- using System.Runtime.InteropServices;
- using Wrox.ProCSharp.COMInterop.Server;
- namespace Wrox.ProCSharp.COMInterop
- {
- /// <summary>
- /// Summary description for Class1.
- /// </summary>
- class Class1
- {
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void Main(string[] args)
- {
- COMDemo obj = new COMDemoClass();
-
- IWelcome welcome = (IWelcome)obj;
- Console.WriteLine(welcome.Greeting("Christian"));
- obj.Completed += new ICompletedEvents_CompletedEventHandler(Completed);
- IMath math = (IMath)welcome;
- int result = math.Add(3, 5);
- Console.WriteLine(result);
-
- Marshal.ReleaseComObject(math);
- }
- private static void Completed()
- {
- Console.WriteLine("Calculation completed");
- }
- }
- }