**

1.静态:

**
1).在类中声明static类,则其是这个类的共享变量,当某个实例之中的数值发生便哈的时候,所有实例之中的该值均将放生变化。
2).而使用从const创建类的时候,属性一旦声明便不能被改变。

2.方法的重载:

当对于某一个类进行重载的时候,岂会针对于输入的变量,调用不同的实现方式,从而实现重载。

3.泛型:

1)函数中使用:
public T GenericMethod<T>(T param)//基类
public T GenericMethod<T>(T param) where T:class //限定类型为类
public T GenericMethod<T>(T param) where T:struct//限定为值
public T GenericMethod<T>(T param) where T:某个类名//限制为某种类
public T GenericMethod<T>(T param) where T:接口//限定为某个接口
2).类中使用:
		using UnityEngine;
		using System.Collections;
		
	//这是一个通用类。注意通用类型“T”。
	//“T”将被替换为实际类型,同样,
	//该类中使用的“T”类型实例也将被替换。
	public class GenericClass <T>
	{
		T item;
		public void UpdateItem(T newItem)
		{
   			 item = newItem;
		 }
	}

4.继承:

继承之中每个类的构造函数时独立的,而子类在构造的时候会自动继承父类。

5.多态:

1)parentClass myClass = new ChildClass();调用的是子类的构造函数,但是myclass是父类,只能调用父类之中的方法。
		
		2)虚函数例外是因为其在构造的时候会覆盖原有函数。
		3)强制转型 :
				利用上述例子:parentClass myClass = new ChildClass();
				ChildClass childMyClass = myClass as ChildClass; 
				或者 ChildClass childMyClass =(ChildClass)myClass ;

6.成员隐藏:

派生类之中重新生成父类之中的成员称为成员隐藏。即将父类对象
		using UnityEngine;
		using System.Collections;

		public class Humanoid
		{
		 //Yell 方法的基版本
			public void Yell()
		 {
   		 Debug.Log ("Humanoid version of the Yell() method");
    }
}

Enemy 类 
using UnityEngine;
using System.Collections;

public class Enemy : Humanoid
{
    //这会隐藏 Humanoid 版本。
    new public void Yell()
    {
        Debug.Log ("Enemy version of the Yell() method");
    }
}


Orc 类
using UnityEngine;
using System.Collections;

public class Orc : Enemy
{
    //这会隐藏 Enemy 版本。
    new public void Yell()
    {
        Debug.Log ("Orc version of the Yell() method");
    }
}

WarBand 类
using UnityEngine;
using System.Collections;

public class WarBand : MonoBehaviour 
{
    void Start () 
    {
        Humanoid human = new Humanoid();
        Humanoid enemy = new Enemy();
        Humanoid orc = new Orc();

        //注意每个 Humanoid 变量如何包含
        //对继承层级视图中
        //不同类的引用,但每个变量都
        //调用 Humanoid Yell() 方法。
        human.Yell();
        enemy.Yell();
        orc.Yell();
    }
}

7:覆盖(overriding)

子类之中对于积累之中的虚函数进行重写,从而进行覆盖。在父类之中就可以调用子类重写的方法。

8.接口:

能够使得不同类实现相同的方法,其区别与继承的醉倒有点是,一个派生类只能继承自一个父类,但是其却能够继承多个接口。
		using UnityEngine;
using System.Collections;

//这是只有一个必需方法的基本
//接口。
public interface IKillable
{
    void Kill();
}

//这是一个通用接口,其中 T 是
//将由实现类提供的数据类型的
//占位符。
public interface IDamageable<T>
{
    void Damage(T damageTaken);
}

Avatar 类
using UnityEngine;
using System.Collections;

public class Avatar : MonoBehaviour, IKillable, IDamageable<float>
{
    //IKillable 接口的必需方法
    public void Kill()
    {
        //执行一些有趣操作
    }

    //IDamageable 接口的必需方法
    public void Damage(float damageTaken)
    {
        //执行一些有趣操作
    }
}

9.拓展方法:

必须放在一个无泛型的静态类。
			using UnityEngine;
			using System.Collections;

			//创建一个包含所有扩展方法的类
			//是很常见的做法。此类必须是静态类。
			public static class ExtensionMethods
			{
   				 //扩展方法即使像普通方法一样使用,
   					 //也必须声明为静态。请注意,第一个
   				 //参数具有“this”关键字,后跟一个 Transform
    			//变量。此变量表示扩展方法会成为
    				//哪个类的一部分。
    		public static void ResetTransformation(this Transform trans)
    		{
        		trans.position = Vector3.zero;
       			 trans.localRotation = Quaternion.identity;
        		trans.localScale = new Vector3(1, 1, 1);
   			 }
		}
		using UnityEngine;
		using System.Collections;

		public class SomeClass : MonoBehaviour 
		{
		    void Start () {
        		//请注意,即使方法声明中
       			 //有一个参数,也不会将任何参数传递给
       			 //此扩展方法。调用此方法的
        		//Transform 对象会自动作为
       			 //第一个参数传入。
        		transform.ResetTransformation();
    				}
		}

10.abstract和virtual的区别:

1).抽象类不能被实例化,只能被继承,而且抽象方法必须在子类之中必须实现
	2).虚拟方法是被实现的方法,其是被实现的方法,而在其子类之中能够被覆盖