I have a class called Config with the declaration
public class Config<T> where T : class, new()
It contains some methods to save a configuration of type T as well as the actual configuration in property called Configuration.
Is it possible to expose the configuration of type T directly in my Config class without having to go through the Configuration property.
So far, I have a bit of an ugly work around
public T this[int index]
{
get { return _configuration; }
}
If not, then I was wondering if it can be done by inheriting from the T, but I’m not clear on the syntax of how to do this.
Edit:
I imagined you could do something like
public T this
{
get { return _configuration; }
}
You can use an implicit operator:
Use it like so: