Changing class variables

Is there a way to do this:

EDIT: I changed the code below

enum ItemType { 
	Resource = 0, 
	Weapon = 1,
	Medical = 2,
	Building = 3
}

enum MedicalType {
	Heal = 0,
	Feed = 1,
	Drink = 2,
	Multiple = 3
}

class item {
	var Name : String;
 	var Type : ItemType = ItemType.Resource;
	var texture : Texture2D;
	if (Type == ItemType.Building) {	
		var Building : GameObject;
	}
	if (Type == ItemType.Medical) {
		var MedType : MedicalType = MedicalType.Heal;
		var MedicalAmount : int;
	}
	if (Type == ItemType.Weapon) {
		var Weapon : GameObject;
		var AmmoType : String;
		var Range : float;
	}
}

Yes, but the code would be meaningless given both integers within the enum are currently set to the same value. Also, you can’t declare a variable within the if-statement and then not use it.

Use C# and polymorphism:

public abstract class item{
public string name;
}

public class resource:item{
public Texture2D texture;
}

public class weapon:item{
public int count;
}