C
C#8mo ago
Trapyy

Switch statement dont work with variables

string strCursor = i18n.Get("config.detectionMethod.cursor");
string strPlayer = i18n.Get("config.detectionMethod.player");

switch (Config.DetectionMethod)
{
case strCursor:
CheckTile(currentLocation, cursorTile, player);
break;
case strPlayer:
CheckTile(currentLocation, toolLocation, player);
break;
}
string strCursor = i18n.Get("config.detectionMethod.cursor");
string strPlayer = i18n.Get("config.detectionMethod.player");

switch (Config.DetectionMethod)
{
case strCursor:
CheckTile(currentLocation, cursorTile, player);
break;
case strPlayer:
CheckTile(currentLocation, toolLocation, player);
break;
}
is it possible to make this work while using switch statement?
2 Replies
Jimmacle
Jimmacle8mo ago
case values need to be constants you can work around it using pattern matching but it's ugly
Trapyy
TrapyyOP8mo ago
will use ifs then 👍
Want results from more Discord servers?
Add your server