首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

C#编写Com有关问题

2012-02-14 
C#编写Com问题[Guid(A5B6C9F1-E4BE-4910-8EBA-2F8D1B06AB94)]public interface ITest{[DispId(0)] strin

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 接口中的方法必须实现,你只要实现了街口的方法就是正确的,建议在看看面向对象编程

热点排行