A Variable that can hold different class Objects

I’ve 2 classes :

[System.Serializable] public class A  {
	[SerializeField]	public bool apply;
	[SerializeField]	public float pointInSpeedDuration ;
	[SerializeField]	public float pointIntervalbetweenSpeedUp ;
	[SerializeField]    public float variablePointSpeed ;
}

[System.Serializable] public class B{
	[SerializeField]	public bool apply;
	[SerializeField]	public float reverseDuration ;
}

Somewhere in a third class I’m creating object of these classes :

public class LevelController : MonoBehaviour {
    public int levelIndex ;
    public A objA = new A();
    public B objB = new B();
    
}

However I need only one class(A or B) at a time ,

please let me know if I can do something so that I can have a single variable which can hold class A or B:

public class LevelController : MonoBehaviour {
    public int levelIndex ;
    public var obj = new A();
//OR
    public var obj = new B();
}

for me, “var” is not working in the above example

What you are looking for is called Inheritance. You can find a lot of information about this on google.

http://unity3d.com/learn/tutorials/modules/intermediate/scripting/inheritance