Generics And Interfaces....

I'm currently trying to use generics to make my interfaces a little bit more flexible.
Unfortunately I seem to have hit a problem with the compiler complaining when I try to use an interface as an input parameter, if that interface requires a type to be defined.

I'm not sure if I explained that at all well, but given the following example, the compiler complains that I haven't specified a type in the defintion of someMethod. I've tried putting in <T> but it still complains. It only works if I strongly type (by putting <string> in there.



//An underlying type to hold some data.

public interface IDic<T>: IDictionary<string, T>
{
T this[string key]
{
get;
set;
}
}

//A higher level object which uses the underlying type plus some others.
public interface IFoo<T>
{
IDic<T> someProperty
{
get;
set;
}
}

//Something that takes the object in and does something with it.
public interface IBar
{
bool someMethod(IFoo foo);
}



I really don't want to strongly type at the IBar level and would prefer that I could genericise this somehow. Does anyone have any ideas?

[1662 byte] By [DarrenBlackett] at [2008-2-24]
# 1
D'oh, solved it myself. In effect I had to update IBar to do this...

public interface IBar<T>
{
bool someMethod(IFoo<T> foo);
}

DarrenBlackett at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# Language...
# 2
Depending on what IBar is supposed to do, you might want to also consider...


//Something that takes the object in and does something with it.
public interface IBar
{
bool someMethod<T>(IFoo<T> foo);
}

dkocur2 at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# Language...