© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
3 replies
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?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Continue a switch statement
C#CC# / help
3y ago
❔ Comparison in switch statement
C#CC# / help
4y ago
✅ Using Params with Pattern Matching Switch statement
C#CC# / help
2y ago