© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
6 replies
smiley303

❔ Comparison in switch statement

I am having trouble understanding this error (12,10): error CS1525: Invalid expression term '=='
// SKU = Stock Keeping Unit
string sku = "01-MN-L";

string[] product = sku.Split('-');

string type = "";
string color = "";
string size = "";

switch (product[0])
{
    case == "01":
        break;
}
// SKU = Stock Keeping Unit
string sku = "01-MN-L";

string[] product = sku.Split('-');

string type = "";
string color = "";
string size = "";

switch (product[0])
{
    case == "01":
        break;
}


Is it not valid to compare equality in switch statement, i am having bad brain fog right now.
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

✅ Weird InvalidDataException in switch statement
C#CC# / help
4y ago
❔ alternative to switch statement or if statements?
C#CC# / help
4y ago
❔ Continue a switch statement
C#CC# / help
3y ago