class1.cs
来自「Com组件的一些例程」· CS 代码 · 共 42 行
CS
42 行
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");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?