C# 接口
接口实际上就是抽象类,因为在编译IL后为抽象类
// ConsoleApp1.ITest
public interface ITest
{
string Name
{
get;
set;
}
void OnClick();
}
-------------------------------------------
.class interface public auto ansi abstract ConsoleApp1.ITest
{
// Methods
.method public hidebysig newslot abstract virtual
instance void OnClick () cil managed
{
} // end of method ITest::OnClick
.method public hidebysig specialname newslot abstract virtual
instance string get_Name () cil managed
{
} // end of method ITest::get_Name
.method public hidebysig specialname newslot abstract virtual
instance void set_Name (
string 'value'
) cil managed
{
} // end of method ITest::set_Name
// Properties
.property instance string Name()
{
.get instance string ConsoleApp1.ITest::get_Name()
.set instance void ConsoleApp1.ITest::set_Name(string)
}
接口实际上就是抽象类,因为在编译IL后为抽象类
// ConsoleApp1.ITest
public interface ITest
{
string Name
{
get;
set;
}
void OnClick();
}
-------------------------------------------
.class interface public auto ansi abstract ConsoleApp1.ITest
{
// Methods
.method public hidebysig newslot abstract virtual
instance void OnClick () cil managed
{
} // end of method ITest::OnClick
.method public hidebysig specialname newslot abstract virtual
instance string get_Name () cil managed
{
} // end of method ITest::get_Name
.method public hidebysig specialname newslot abstract virtual
instance void set_Name (
string 'value'
) cil managed
{
} // end of method ITest::set_Name
// Properties
.property instance string Name()
{
.get instance string ConsoleApp1.ITest::get_Name()
.set instance void ConsoleApp1.ITest::set_Name(string)
}
} // end of class ConsoleApp1.ITest
在 nameSpace 下,不能定义字段,属性,方法,因为这些东西一定会属于更高级的。
可以定义类,委托,枚举,接口,结构体,