Question: I have an interface that looks like this:

```
public interface IOpportunity
{
    string Name { get; }
    string Description { get; }
    ILocation Location { get; }
}

public interface ILocation : IHierarchicalEntity 
{ 
    int OpptyCount { get; }
}

public interface IHierarchicalEntity 
{ 
    string SID { get; }
    string Name { get; }
}

```

However, I want the ILocation object to also implement ONE of these interfaces:

```
public interface IHierarchicalEntityWithParentNames : IHierarchicalEntity
{
    /// <summary>
    /// Returns the lowest level that this heirarchy goes (0 for a flat hierarchy, 1 for a two-level etc.)
    /// </summary>
    int LeafLevel { get; }

    /// <summary>
    /// Returns the name of the Segment for the given level (0 for a root node, n for leaf node, where n = LeafLevel)
    /// </summary>
    /// <param name="level"></param>
    /// <returns></returns>
    string GetNameForLevel(int level);
}

public interface IHierarchicalEntityWithParentIds : IHierarchicalEntity
{
    IHierarchicalEntityWithParentIds ParentEntity { get; }
    string ParentSID { get; }
}

```

Due to the nature of the code I am writing, I cannot combine these interfaces into one interface that has some sort of `GetParent` method

In the code that consumes these interfaces, I have two classes - one that consumes the ILocation object if it is an `IHierarchicalEntityWithParentNames` and another if it is an `IHierarchicalEntityWithParentIds`

How would I lay out the interfaces (perhaps I have to have some abstract classes) to support having this "one or the other" design?

Answer: 
You can't. You either explicitly implement an interface, or you don't. What you're describing is effectively "either method A *or* method B will exist," but that's not a concept that exists in C# (or any other language that I'm aware of!).

The closest you'll be able to get would be to throw an exception in the code that consumes your interface if the class doesn't also implement one of the other two interfaces.

Alternatively, I imagine you could have a base class whose constructor will throw an exception if it doesn't also implement one or other of the interfaces. This would give you an earlier check, but it's still a runtime check and, personally, I think it's a horrible idea.
I am not aware of any way to enforce this at compile time. I think you would have to make this a runtime check by using a base class that throws an exception if both interfaces are implemented.

However, that won't stop someone from bypassing your base class and implementing the interfaces themselves, and I know of no way to prevent that.