Created
February 14, 2023 11:12
-
-
Save profesor79/17c18982fffa07b537ec2832714b1993 to your computer and use it in GitHub Desktop.
if VS switch - a total war
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SwitchStuff | |
{ | |
[Benchmark] | |
[Arguments("ThisIsCase1")] | |
[Arguments("ThisIsCase2")] | |
[Arguments("ThisIsCase3")] | |
[Arguments("ThisIsCase4")] | |
[Arguments("ThisIsCase5")] | |
public string ProcessSwitchWithString(string matchCase) | |
{ | |
switch (matchCase) | |
{ | |
case "ThisIsCase1": | |
return "case1"; | |
case "ThisIsCase2": | |
return "case2"; | |
case "ThisIsCase3": | |
return "case3"; | |
case "ThisIsCase4": | |
return "case4"; | |
case "ThisIsCase5": | |
return "case5"; | |
} | |
return string.Empty; | |
} | |
} | |
public class IfStuff | |
{ | |
[Benchmark] | |
[Arguments("ThisIsCase1")] | |
[Arguments("ThisIsCase2")] | |
[Arguments("ThisIsCase3")] | |
[Arguments("ThisIsCase4")] | |
[Arguments("ThisIsCase5")] | |
public string ProcessIfWithString(string matchCase) | |
{ | |
if (matchCase == "ThisIsCase1") | |
{ | |
return "case1"; | |
} | |
else if (matchCase == "ThisIsCase2") | |
{ | |
return "case2"; | |
} | |
else if (matchCase == "ThisIsCase3") | |
{ | |
return "case3"; | |
} | |
else if (matchCase == "ThisIsCase4") | |
{ | |
return "case4"; | |
} | |
else if (matchCase == "ThisIsCase5") | |
{ | |
return "case5"; | |
} | |
return string.Empty; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment