关于new 一个接口的有意思的代码

using System;
using System.Runtime.InteropServices;
namespace Test
{
    
    internal class A:IA
    {
        public void Hello()
        {
            Console.WriteLine("Hello World");
        }
    }
    [CoClass(typeof(A))]
    [ComImport]
    [Guid("664DD00E-1469-42EA-825F-CFE2D8C4E528")]
    internal interface IA
    {
        void Hello();
    }


    internal static class Program
    {
        static void Main(string[] args)
        {
            IA a = new IA();
            a.Hello();
            Console.ReadLine();
        }

    }
}

 

posted @ 2024-09-02 11:34  stweily  阅读(3)  评论(0编辑  收藏  举报