I am having a HotDog class as a child of Food class.
public class HotDog : Food
{
public HotDog () : base ("hotdog", new string[] { "bread", "meat"}, new int[] { 1, 1 }, 0.7)
{
}
}
I tried to do this
Type t = typeof("HotDog");
if (t is Food) {
Food f = (Food)Food.CreateOne (t);
}
This is my CreateOne method
public static Consumables CreateOne (Type t)
{
return (Consumables)Activator.CreateInstance (t);
}
But I got the error that t is never of the provided Food type so the code inside is unreachable. Any idea what's wrong with this thing and how can I fix it?