Based on your reply to Josh_Jackson, I'd suggest that you use an interface to constrain both types. If they are completely different functionality, but share the same public contract then you can instantiate from the interface:
public interface IFoo
{
void DoSomething();
}
public class Foo : IFoo
{
public void DoSomething()
{
Console.WriteLine("Foo");
}
}
public class Bar : IFoo
{
public void DoSomething()
{
Console.WriteLine("Foo");
}
}
Then, you can use this by referencing the interface as the type (and instantiating it with the concrete implementation):
IFoo instance = null;
if (somecondition)
{
instance = new Foo();
}
else
{
instance = new Bar();
}
instance.DoSomething();