❔ Can i not call a non static Method in a interface?
publicinterfaceIRegistry<B> {
publicvirtualvoidInitialize() {
}
public T Register<T>(string name, Dictionary<string, object> registryList, T config) where T : B {
registryList.Add(name, config);
return config;
}
}
MrScautHD2/20/2023
Guys how can i call a non static method in a interface?
thinker2272/20/2023
You can't™️
MrScautHD2/20/2023
ouff
thinker2272/20/2023
That method comes from the interface, not the type ConfigRegistry itself
MrScautHD2/20/2023
yea but i extend from it
thinker2272/20/2023
And in general you shouldn't do this in interfaces, an interface should be a contract and nothing else
thinker2272/20/2023
and also you can just shorten the definition of Initialize to
voidInitialize();
MrScautHD2/20/2023
oh yea thx
thinker2272/20/2023
What you could do is have an abstract class RegistryBase<B> which implements the interface and defines the Register method