接口的简单使用
interface
一个接口定义一个协定。实现接口的类或结构必须遵守其协定。声明采用下列形式:
[attributes] [modifiers] interface identifier [:base-list] {interface-body}[;] 
其中: 
- attributes(可选) 
- 附加的声明性信息。有关属性和属性类的更多信息,请参见 17. 属性 。
- modifiers(可选) 
- 允许使用的修饰符有 new 和四个访问修饰符。 
- identifier 
- 接口名称。 
- base-list(可选) 
- 包含一个或多个显式基接口的列表,接口间由逗号分隔。 
- interface-body 
- 对接口成员的声明。
 
 
 public interface IDInterface
 {
 DataSet GetManyTable(string []SelectSql , string []TableName);
 void ExcuteSqlCommand(string SqlCommandString);
 }
 
 public class ClassData : IDInterface
 {
 public DataSet GetManyTable(string []SelectSql, string []TableName)
 {
 ................
 //省去中间实现过程
 ..........
 }
 public void ExcuteSqlCommand(string strSqlCmd)
 {
 //省去中间实现过程
 }
 }
public interface IDInterface
{
DataSet GetManyTable(string []SelectSql , string []TableName);
void ExcuteSqlCommand(string SqlCommandString);
}
public class ClassData : IDInterface
{
public DataSet GetManyTable(string []SelectSql, string []TableName)
{
................
//省去中间实现过程
..........
}
public void ExcuteSqlCommand(string strSqlCmd)
{
//省去中间实现过程
}
}
 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号