asp.net 项目接口怎么用

来源:百度知道 编辑:UC知道 时间:2024/06/25 02:46:34
我正在做一个项目,给我一接口,但在基类中却什么只写了类名,那么我在接口中和继承接口的类中又该写一些什么
能具体说明一下吗

An interface contains only the signatures of methods, delegates or events. The implementation of the methods is done in the class that implements the interface, as shown in the following example:

interface ISampleInterface
{
void SampleMethod();
}

class ImplementationClass : ISampleInterface
{
// Explicit interface member implementation:
void ISampleInterface.SampleMethod()
{
// Method implementation.
}

static void Main()
{
// Declare an interface instance.
ISampleInterface obj = new ImplementationClass();

// Call the member.
obj.SampleMethod();
}
}

Remarks
An interface can be a member of a namespace or a class and can contain signatures of the following members:
Methods
Properties
Indexers
Events

An interface can inherit from one or more base int