One possible solution would be to use a generic class with an interface constraint. So the declaration would look something like:
public class MyClass<TShape> where TShape : IShape
{
protected TShape Bounds;
//Rest of class
}
Alternatively, you could provide access to the shape through a generic method which would centralize where the casting is done:
public class MyClass
{
private IShape Bounds;
protected TShape GetBounds<TShape>() where TShape : IShape
{
return (TShape)Bounds; //Note this will throw an exception if the wrong shape is specified
}
//Rest of class
}
The former is more appropriate if the base class should take responsibility for knowing its own shape type. The latter is more appropriate if the base class should remain ignorant of its shape type while the inheriting class (or calling class if you make things public) should know.
However, while one of these solutions might fit your situation pretty well, having to do it at all is a bit of a code smell. There's not much point to using an interface if your classes are going to have to know and track the specific concrete class most of the time. The best solution might be changing your design, though it's hard to give advice on that without seeing more of what you have.