接口和抽象类的区别:
1.接口用于规范,抽象类用于共性。
2.接口中只能声明方法,属性,事件,索引器。而抽象类中可以有方法的实现,也以定义非静态的类变量。
3.抽象类是类,所以只能被单继承,但是接口却可以一次实现多个。
4.抽象类可以提供某些方法的部分实现,接口不可以。
5.抽象类的实例是它的子类给出的。接口的实例是实现接口的类给出的
6.在抽象类中加入一个方法,那么它的子类就同时有了这个方法。而在接口中加入新的方法,那么实现它的类就要重新编写(这就是为什么说接口是一个类的规范了)。
7.接口成员被定义为公共的,但抽象类的成员也可以是私有的、受保护的、内部的或受保护的内部成员(其中受保护的内部成员只能在应用程序的代码或派生类中访问)。
8.此外接口不能包含字段、构造函数、析构函数、静态成员或常量。
内连接(Inner join)
内链接就是对表A和表B以元组为单位做一个笛卡尔积,记为表C,然后在C中挑选出满足符合on 语句后边的限制条件的条目。
成多表的查询在控制台输出
- public ArrayList show() {
- ArrayList list = new ArrayList();
- SqlConnection con = He.Connert();
- con.Open();
- string sql = "select equment.name,equment.price,grade.score from equment inner join grade on equment.id=grade.sid ";
- SqlCommand sc = new SqlCommand(sql, con);
- SqlDataReader reader=sc.ExecuteReader ();
- while (reader.Read()) {
- equment e = new equment();
- e.Name = (string)reader.GetValue(0);
- equment e2 = new equment();
- e2.Price = (int)reader.GetValue(1);
- Grade g = new Grade();
- g.Scroce = (int)reader.GetValue(2);
- list.Add(e);
- list.Add(e2);
- list.Add(g);
- }
- He.Close(con,reader );
- return list;
- }
-
- public void student() {
- ArrayList list = new Grade().show();
- IEnumerator it = list.GetEnumerator();
- while (it.MoveNext())
- {
- equment e = (equment)it.Current;
- it.MoveNext();
- equment e2 = (equment)it.Current;
- it.MoveNext();
- Grade g = (Grade)it.Current;
- Console.WriteLine(e.Name + " " + e2.Price + " " + g.Scroce);
- }
复制代码
|