Obligatory I'm new to C# and am working on a large project for work and have run into a wall google can't seem to help me solve.
I understand that case's need to be constant and I am using a variable to declare a case but I can't seem to find the right way to correct the issue.
I am using the code to determine whether or not to send an order message to a market.
The defined variable
private string[] m_oKeys = new string[1];
The switch with the issue
public void m_ts_OrderAdded(object sender, OrderAddedEventArgs e)
{
string key = e.Order.SiteOrderKey;
switch (key)
{
case m_oKeys[1]:
m_oObject = new e.Order();
m_oKeys = new e.Order.SiteOrderKey();
m_InFlight = new (false);
break;
case m_oKeys[]:
m_oObject[] = e.Order;
m_oKeys(1) = e.Order.SiteOrderKey;
m_InFlight(1) = false;
break;
default:
break;
//handle order not found...
}
}
case m_oKeys[]intended to match given there is no index specified ...?case "key1":. You can't use a variable here. Instead write out the switch-statement as a series ofif-statements. Also, what is this supposed to match?case m_oKeys[]:<-- no index