System.Convert.CalculateOutputLength C# (CSharp) Method

CalculateOutputLength() private static method

private static CalculateOutputLength ( int inputLength, bool insertLineBreaks ) : int
inputLength int
insertLineBreaks bool
return int
        private static int CalculateOutputLength(int inputLength, bool insertLineBreaks) {
            int outlen = (int)( inputLength / 3 * 4);           // the base length - we want integer division here. 
            outlen += ((inputLength % 3) != 0) ? 4 : 0;         // at most 4 more chars for the remainder

            if (outlen ==0 )
                return outlen;

            if (insertLineBreaks) {
                int newLines = outlen / 76;
                if( (outlen % 76) == 0) {
                    --newLines;    
                }
                outlen += newLines * 2;              // the number of line break chars we'll add, "\r\n"
            }
            return outlen;
        }