Conversions.ToBoolean vs Convert.ToBoolean

Viewed 49

I have been transforming and old VB project into C# one, using CodeConverter. The tool used to transform all the expressions such as:

CBool(objectUnit.UnitType And HrUnitTypeEnum.CanHaveEmployment) into:

Conversions.ToBoolean(objectUnit.UnitType & HrUnitTypeEnum.CanHaveEmployment)

where UnitType is of type HrUnitTypeEnum.

It is strange to me that it would use Microsoft.VisualBasic.CompilerServices.Conversions.ToBoolean() instead of System.Convert.ToBoolean().

At first glance it all looked to work fine, but when I have done memory profiling, there have been repeteadly the cases where the conversion would be exceptionally time consuming: enter image description here

Are there any corner cases where those conversions differ? Should I perform binary operation on enums parsed to integers?

0 Answers
Related