[100分]请讲述接口的属性,概念,应用!谢谢,立即给分 [100分]请讲述接口的属性,概念,应用!谢谢,立即给分 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 请看:http://blog.csdn.net/chengking/archive/2005/11/16/530684.aspx C# 程序员参考 interface请参见C# 关键字 | 引用类型 | 属性 | 索引器 | C. 语法 | 显式接口实现教程 | class | struct一个接口定义一个协定。实现接口的类或结构必须遵守其协定。声明采用下列形式:[attributes] [modifiers] interface identifier [:base-list] {interface-body}[;]其中: attributes(可选) 附加的声明性信息。有关属性和属性类的更多信息,请参见 17. 属性。 modifiers(可选) 允许使用的修饰符有 new 和四个访问修饰符。 identifier 接口名称。 base-list(可选) 包含一个或多个显式基接口的列表,接口间由逗号分隔。 interface-body 对接口成员的声明。 备注接口可以是命名空间或类的成员,并且可以包含下列成员的签名: 方法 属性 索引器 事件 一个接口可从一个或多个基接口继承。在下例中,接口 IMyInterface 从两个基接口 IBase1 和 IBase2 继承:interface IMyInterface: IBase1, IBase2{ void MethodA(); void MethodB();}接口可以由类和结构实现。实现的接口的标识符出现在类的基列表中。例如:class Class1: Iface1, Iface2{ // class members}类的基列表同时包含基类和接口时,列表中首先出现的是基类。例如:class ClassA: BaseClass, Iface1, Iface2 { // class members}有关接口的更多信息,请参见接口。有关属性和索引器的更多信息,请参见属性声明和索引器声明。示例下例说明了接口的实现。在此例中,接口 IPoint 包含属性声明,后者负责设置和获取字段的值。MyPoint 类包含属性实现。// keyword_interface.cs// Interface implementationusing System;interface IPoint { // Property signatures: int x { get; set; } int y { get; set; }}class MyPoint : IPoint { // Fields: private int myX; private int myY; // Constructor: public MyPoint(int x, int y) { myX = x; myY = y; } // Property implementation: public int x { get { return myX; } set { myX = value; } } public int y { get { return myY; } set { myY = value; } }}class MainClass { private static void PrintPoint(IPoint p) { Console.WriteLine("x={0}, y={1}", p.x, p.y); } public static void Main() { MyPoint p = new MyPoint(2,3); Console.Write("My Point: "); PrintPoint(p); }}输出My Point: x=2, y=3 做网店的支付系统该怎么实现? ajax局部更新的问题 好多B/S软件打开时都会没有菜单栏,怎么实现? ADO.NET要学到什么程度 下拉列表框读取问题 工具栏问题 DataTable中的移除问题。 树的问题 我想把另外两张表 里面的部分内容页显示出来,怎么做啊,急急急!!! 我想要做一个信息输入表单,谁能给我原代码啊?详情请看内容!!!!高手们帮帮我啦!!!! 权限判断问题!!1 ASP.NET Web Matrix 中使用Web控件
http://blog.csdn.net/chengking/archive/2005/11/16/530684.aspx
C# 关键字 | 引用类型 | 属性 | 索引器 | C. 语法 | 显式接口实现教程 | class | struct
一个接口定义一个协定。实现接口的类或结构必须遵守其协定。声明采用下列形式:[attributes] [modifiers] interface identifier [:base-list] {interface-body}[;]
其中: attributes(可选)
附加的声明性信息。有关属性和属性类的更多信息,请参见 17. 属性。
modifiers(可选)
允许使用的修饰符有 new 和四个访问修饰符。
identifier
接口名称。
base-list(可选)
包含一个或多个显式基接口的列表,接口间由逗号分隔。
interface-body
对接口成员的声明。
备注
接口可以是命名空间或类的成员,并且可以包含下列成员的签名: 方法
属性
索引器
事件
一个接口可从一个或多个基接口继承。在下例中,接口 IMyInterface 从两个基接口 IBase1 和 IBase2 继承:interface IMyInterface: IBase1, IBase2
{
void MethodA();
void MethodB();
}
接口可以由类和结构实现。实现的接口的标识符出现在类的基列表中。例如:class Class1: Iface1, Iface2
{
// class members
}
类的基列表同时包含基类和接口时,列表中首先出现的是基类。例如:class ClassA: BaseClass, Iface1, Iface2
{
// class members
}
有关接口的更多信息,请参见接口。有关属性和索引器的更多信息,请参见属性声明和索引器声明。示例
下例说明了接口的实现。在此例中,接口 IPoint 包含属性声明,后者负责设置和获取字段的值。MyPoint 类包含属性实现。// keyword_interface.cs
// Interface implementation
using System;
interface IPoint
{
// Property signatures:
int x
{
get;
set;
} int y
{
get;
set;
}
}class MyPoint : IPoint
{
// Fields:
private int myX;
private int myY; // Constructor:
public MyPoint(int x, int y)
{
myX = x;
myY = y;
} // Property implementation:
public int x
{
get
{
return myX;
} set
{
myX = value;
}
} public int y
{
get
{
return myY;
}
set
{
myY = value;
}
}
}class MainClass
{
private static void PrintPoint(IPoint p)
{
Console.WriteLine("x={0}, y={1}", p.x, p.y);
} public static void Main()
{
MyPoint p = new MyPoint(2,3);
Console.Write("My Point: ");
PrintPoint(p);
}
}
输出
My Point: x=2, y=3