下面是我参考书上将有用的东西整理了一下供大家参考,学习:
Visual c#.NET
1 关键字 base
   (1) 在前面基类和派生类的程序中,已使用了base关键字调用基类的字段和方法。若调用被隐藏的积累的成员,则base是必须的,
       在前面基类和派生类的程序中,41和44行中,热访问被继承但是没有被签名相同的派生类成员的基类成员,则不必使用base
       关键字,因为他们在派生类中仍是唯一的。
   (2)使用base调用基类的构造函数
        派生类继承基类中除了构造函数,析构函数以外的所有成员,但是,派生类仍然可以调用直接基类的构造函数。
        将着个构造函数改造如下:
    

public CollegeStudent(string deptmnt,sting str,string bStudName,int id):base(bStudName,id) 
        {   department=deptmnt; 
           studName=str; 
         }


   (3)使用base应注意点
      base和this一样是指对象的,因此不能用做静态方法和静态构造函数中,也不能通过bade和this访问其它静态成员.
      直接基类也可以是派生类,直接基类中拥有来自它自己的基类的成员,派生类中使用base关键字不区分直接基类成员的来源,都同样用base 来访问.
派生类使用base只能调用直接基类的构造函数.
只能在派生类内使用base访问基类的被隐藏的成员,在派生类之外,不能通过派生类的对象访问被隐藏的成员.在前面基类和派生类的程序中的FindInfo方法,不能用ACollegeStudent.base.FindInfo.派生类FindInfo3实际是间接调用基类的隐藏方法.
2 访问控制符
   (1) 访问控制符有:

public,pritected,internal,protected internal,private 
   public 访问不受限制 
   pritected   被所在的类和该类的派生类访问 
   internal    被该类所在的程序集访问 
   protected internal   包含类,包含类的派生类,所在的程序集 
   private 包含类


   如果没有对类成员是用的访问控制每那么该成员被默认为private可访问性,规定类成员的默认访问控制符为private .
   (2)继承private 成员和protected成员
      基类的private 成员被派生类继承后门牌胜利拥有基类的private 成员,但是派生类中新定义的方法不能访问来自基类的 private成员.派生类的成员分为继承基类的部分和新定义的部分,来自基类的private 只能被来自基类的方法所调用.
      (protected)受保护的类成员和私有的类成员在没有继承的条件下是一样的,在继承的关系的情况下,因为派生类由两部分组成,一部分是来自基类的,另一部分是派生类天家的成员,对于基类的private成员,其可访问性只限来自基类的部分;而基类的protected 成员的可访问为派生类的全部.并且继承是可传递的.   
程序1

using System; 
using System.Collections.Generic; 
using System.Text; 

namespace school 
{ 
    public class BasCls 
     { 
        protected int x; 
        public void Func(BasCls a, DerCls1 b, DerCls2 c) 
        { 
            a.x = 1; 
            b.x = 1; 
            //c.x=1; 
            //c.y=1; 
            Console.WriteLine("a.x={0} b.x={1} c.x={2}",a.x ,b.x,c.x); 
        } 
    } 
     public class DerCls1:BasCls  
     { 
         public void Func(BasCls a,DerCls1 b) 
         { 
             //a.x=1; 
               b.x=4; 
         } 
     } 
     public class DerCls2:BasCls  
     { 
         new protected int x; 
         protected int y=9; 
         public DerCls2(){} 
         public DerCls2 (int i) 
         { 
             base .x =i; 
         } 
      public int TheX 
      { 
          get {return x;} 
          set {x=value ;} 
      } 
     } 
     public class ATrial 
     { 
       static void Main(string[] args) 
         { 
             BasCls aa = new BasCls(); 
           DerCls1 bb=new DerCls1 (); 
           DerCls2 cc=new DerCls2 (6); 
           cc.TheX=8; 
           Console .WriteLine ("the x in cc="+cc.TheX); 
           aa.Func (aa,bb,cc); 
      } 
    } 
}


程序1的输出为:
     the x in cc=8
     a.x=1    b.x=1    c.x=6
func还访问了b.x,b是派生类DerCls的对象,但是b中的x实际上是继承基类的部分,它回到了基类后,仍然被视为基类的可访问性,因而是合法的语句.派生类DerCls中的添加了x,隐藏了基类的x,添加了整形变量y定义了可以初始化的基类的protected变量x定义了属性TheX,可以让外界访问成员x.
3 嵌套类型,对象成员
   (1) 类的嵌套:在类(或结构)内声明的类型称为嵌套类型或内部类型,而包含着嵌套类的类称为封闭类或外部类型.

例如:public class EnclosingClass 
{//其他成员声明 
     public class NestedClass 
     { 
//嵌套类的成员和代码 
     } 
     //其他成员的声明 
}


4 基类和派生类的转换,as运算符
   派生类的成员至少不少于基类的成员,基类有的派生类都有;但是派生类有的,基类就未必了,例如派生类中新添加的成员,基类中就没有.如果在需要派生类对象的场合却用基类对象来顶替,那么就可能产生缺少方法,缺少数据等,这是兵家之大忌.
   但是,在需要基类的场合,由派生类对象来顶替,则是允许的.因为不会造成程序的安全问题,切可以增加灵活性.   和系统预定义的类型相似,自定义的类型也可以进行强制类型转换,此外,C#中还有一个as运算符可以进行类型转换运算.as的两特点:
as运算符只能用于引用类型,强制转海南无此特点:
如果转换不成功,as运算的结果是nul,而强制转换则抛出异常.
程序2

using System; 
using System.Collections.Generic; 
using System.Text; 

namespace school 
{ 
     public class Student                                 //基类 
     { 
         protected string studName;                      //protected成员 
         protected int studID; 
         public Student() { }                             //基类的无参构造函数 
         public Student(string str, int id)              //基类的构造函数 
         { 
             studName = str; 
             studID = id; 
         } 
         public string TheName                            //属性 
         { 
             get { return studName; } 
         } 
         public void PtingBase()                          //方法 
         { 
             Console.WriteLine("在基类:student."); 
         } 
         public void FindInfo(int id)                      //方法 
         { 
             if (id == studID) 
                 Console.WriteLine("{0}is a srudenr.",studName); 
         } 
     } 
     public class CollegeStudent : Student                 // 派生类 
     { 
         string department;                                 //新添加的成员 
         public CollegeStudent(string deptmnt, string str, int id): base(str, id)//构造函数 
        { 
            department = deptmnt;                                                 
        } 
         public void PrntDReived()                                                // 方法 
         { 
             Console.WriteLine("在派生类:CollegeStudent"); 
         } 
         public new void FindInfo(int id)                                         //方法 
         { 
             if (id == studID) 
                 Console.WriteLine("{0}is atudent in the {1} Department.",studName,department); 
         } 
     } 
     public class Test                                                            //测试  
     { 
         public static void DisplayCls(Student stu)                               //方法 
         { 
             Console.WriteLine("Base or Derived class?" + stu.ToString()); 
         } 
         public static void DisplayObj(Student stu)                               //方法 
         { 
             Console.WriteLine("The Stufent Name is"+stu .TheName); 
         } 
         public static void Main()                                                //main方法 
         { 
             Student StudentA = new Student("李一",0518244); 
             Student StudentB=new CollegeStudent ("计算机","王二",0518255); 
             Student StudentC = new Student("张三",0518266); 
             Student StudentD = new CollegeStudent("计算机","刘四",0518277); 
             CollegeStudent CollegeStudentA = new CollegeStudent("计算机","赵五",0518288); 
             CollegeStudent CollegeStudentB = new CollegeStudent("计算机","陈六",0518299); 
             StudentA = CollegeStudentA;                                          //允许 
             //CollegeStudentA=StudentB;                                          //错误 
             DisplayObj(StudentC); 
             DisplayObj(CollegeStudentB);                                         //形参是基类的对象,实参为派生类对象   
             DisplayCls(StudentC); 
             DisplayCls(CollegeStudentB);                                         // 形参是基类的对象,实参为派生类对象   
             CollegeStudentB = (CollegeStudent)StudentB; 
             //CollegeStudentB = (CollegeStudent)StudentC;                        //编译通过,运行时错误 
             CollegeStudent CollegeStudentC; 
             CollegeStudentC = StudentC as CollegeStudent;                        // as运算符 
             CollegeStudent CollegeStudentD = StudentD as CollegeStudent; 
             if (CollegeStudentC == null) Console.WriteLine("CollegeStudentC is null"); 
             if (CollegeStudentD != null) Console.WriteLine("CollegeStudentD is not null"); 
             CollegeStudentD.FindInfo(0518277); 
         } 
     } 
} 
程序2的输出信息: 
The Student Name is 张三 
The Student Name is 陈六 
Base or Derived class?School.Student 
Base or Derived class ?School.CollegeStudent 
CollegeStudentC is null 
CollegeStudentD is not null 
刘四 is abstract student in the 计算机 Department. 
CollegeStudentB = (CollegeStudent)StudentB;是强制转换类型,由于StudentB的引用指向CollegeStudent对象所属的空间,所以转换成功,比较 CollegeStudentA=StudentB;StudentB不能隐式地转换成   CollegeStudent类型的对象,而CollegeStudentB = (CollegeStudent)StudentC也是强制转换,从语法上是对的,但是引用指向不用,不允许这样的转化,因而会出错.