ReSharper and remove the extra parentheses. OR vs AND in C #

I recently noticed that ReSharper (2016.3) now says to remove redundant parentheses on C # statements, which I believe will lead to a change in the intended behavior. This statement:

private bool GetAutoAdjust( int catType )
{
  return ( catType == ChargeTypeIds.Penalty && _appSettingRepository.AutoRemovePen ) ||
         ( catType == ChargeTypeIds.Interest && _appSettingRepository.AutoRemoveInt ) ||
         ( catType == ChargeTypeIds.Discount && _appSettingRepository.AutoRemoveDis );
}

Really equivalent to this?

private bool GetAutoAdjust( int catType )
{
  return  catType == ChargeTypeIds.Penalty && _appSettingRepository.AutoRemovePen  ||
          catType == ChargeTypeIds.Interest && _appSettingRepository.AutoRemoveInt  ||
          catType == ChargeTypeIds.Discount && _appSettingRepository.AutoRemoveDis ;
}

Perhaps I am mistaken in how C # evaluates OR clauses compared to something like SQL Server, but does not OR evaluates the expression only LEFT from it and right to it, or does it actually pre-concatenate all AND conditions before condition assessment OR?

+4
source share
1 answer

# . , && ||, Resharper , .

, , - . .

+6

Source: https://habr.com/ru/post/1672882/


All Articles