Assume that I have the following function
public static bool RequiresQuotes(this SqlDbType sqlType)
{
switch (sqlType)
{
case SqlDbType.Char:
case SqlDbType.NChar:
case SqlDbType.NText:
case SqlDbType.NVarChar:
case SqlDbType.Text:
case SqlDbType.VarChar:
case SqlDbType.Xml:
case SqlDbType.DateTime:
case SqlDbType.SmallDateTime:
case SqlDbType.Date:
case SqlDbType.Time:
case SqlDbType.DateTime2:
case SqlDbType.DateTimeOffset:
return true;
default:
return false;
}
}
Does it make a performance difference to return true for each case rather than the above, or will it be optimized by the compiler?
For example if I call SqlDbType.Char.RequiresQuotes();
will it check all cases until it reaches SqlDbType.DateTimeOffset
and then returns true or will only check the first case and then return true?