Im trying to make my code faster and i got a lot of If-else and if-or in it. I know that switch case is faster if you got more than 5 if/case. So how fast is if-else
vs. if-or
, is they the same?
if (item.Datum.Substring(5, 5) == "06-20" || item.Datum.Substring(5, 5) == "06-21")
{
Something
}
else if item.Datum.Substring(5, 5) == "06-22" || item.Datum.Substring(5, 5) == "06-23")
{
Something
}
OR
if (item.Datum.Substring(5, 5) == "06-20")
{
Something
}
else if (item.Datum.Substring(5, 5) == "06-21")
{
Something
}
else if (item.Datum.Substring(5, 5) == "06-22")
{
Something
}
else if (item.Datum.Substring(5, 5) == "06-23")
{
Something
}
OR shall i just go with the switch case?
switch(item.Datum.Substring(5, 5))
{
case "06-20", "06,21":
Something
break;
case "06-22", "06,23":
Something
break;
}