日期:2014-05-18  浏览次数:20475 次

C#编写Com问题
[Guid("A5B6C9F1-E4BE-4910-8EBA-2F8D1B06AB94")]
public interface ITest
{
[DispId(0)] string fun();
string fun2();
}

public class test:ITest
{
public test()
{}

public string fun()
{
return "this is fun";
}

public string fun(string v)
{
return "this is override fun" + v;
}
  public string fun2()
{
return "this is fun2";
}
  public string fun3()
{
return "this is fun3";
}
}
问题:1、DispId 是做什么,为什么加不加都可以调用
2、为什么在接口中没声明的方法也可以调用
3、为什么重载不可以,无法调用 fun("dfdf")

------解决方案--------------------
[DispId]这只是一个特性
------解决方案--------------------
回答2 接口中的方法必须实现,你只要实现了街口的方法就是正确的,建议在看看面向对象编程