So, I create a IList<> Like this.
private IList<Agent> m_agentCollection = new List<Agent>();
to add 2 value is macdAgent and rsiAgent
m_agentCollection.Add(macdAgent);
m_agentCollection.Add(rsiAgent);
but in for-loop part
for (int i = 0; i < m_agentCollection.Count; i++)
{
AgentMACD macdAgent = (AgentMACD)m_agentCollection[i];
AgentRSI rsiAgent = (AgentRSI)m_agentCollection[i];
}
I get a Unable to cast object of type '.AgentMACD ' to type '.AgenRSI'.'.
It's because AgentMACD is on index 0 and AgentRSI is on index 1 and how can i get through with this?