3
Need to get an interface to implement a list of a certain type:
public class ITrade<T>
{
public int date { get; set; }
public double price { get; set; }
public double amount { get; set; }
public string type { get; set; }
}
interface ITrades<T>
{
List<ITrade<T>> Trades { get; set; }
}
But I want Itrade to receive as a parameter a concrete class:
public class Trade
{
public int date { get; set; }
public double price { get; set; }
public double amount { get; set; }
public int tid { get; set; }
public string type { get; set; }
}
The idea is this: Trade
is in a template file and I want every template to have at least the properties of ITrade
. That is, I need to force the elements on the list:
List<ITrade<T>> Trades { get; set; }
have at least the properties of ITrade
a few more properties. I can’t put this in ITrade
because I want to separate a general interface that can work with multiple models and I want to keep the models separate.
Did you understand that the solution I posted is what you need? You commented on my answer and then deleted it. I don’t know if it was because you realized it was exactly what you wanted or if you still didn’t understand the solution. Your comment exactly conforms my answer.
– Maniero
Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site.
– Maniero