Inconsistent orientations between Brep and BrepFace

I have a surface which is a Brep and I would like to convert it to BrepFace by the following C# program:

Brep inputBrep = ...
foreach (BrepFace face in inputBrep.Faces)
{ ... }

Though, I found that sometimes the orientation is flipped after the conversion. How to make sure the orientation consistency ?

You probably want to examine the OrientationIsReversed property on BrepFace

Thanks for the solution.

May I ask a follow-up question? Why would the orientation of BrepFace be reversed ?

When surfaces are joined into a polysurface (a Brep) their normals may not be consistent from one face to the next. In that case the OrientationIsReversed flag is set on some of the faces to make the normals consistent across all faces, without changing the underlying surfaces. For closed polysurfaces, the normals must all point outwards.