System.Data.SqlTypes.SqlDecimal.AssertValid C# (CSharp) Method

AssertValid() private method

private AssertValid ( ) : void
return void
        private void AssertValid()
        {
            if (IsNull)
                return;

            // Scale,Prec in range
            Debug.Assert(_bScale <= s_NUMERIC_MAX_PRECISION, "m_bScale <= NUMERIC_MAX_PRECISION", "In AssertValid");
            Debug.Assert(_bScale <= _bPrec, "m_bScale <= m_bPrec", "In AssertValid");
            Debug.Assert(_bScale >= 0, "m_bScale >= 0", "In AssertValid");
            Debug.Assert(_bPrec > 0, "m_bPrec > 0", "In AssertValid");

            Debug.Assert(CLenFromPrec(_bPrec) >= _bLen, "CLenFromPrec(m_bPrec) >= m_bLen", "In AssertValid");
            Debug.Assert(_bLen <= s_cNumeMax, "m_bLen <= x_cNumeMax", "In AssertValid");

            uint[] rglData = new uint[4] { _data1, _data2, _data3, _data4 };

            // highest UI4 is non-0 unless value "zero"
            if (rglData[_bLen - 1] == 0)
            {
                Debug.Assert(_bLen == 1, "m_bLen == 1", "In AssertValid");
            }

            // All UI4s from length to end are 0
            for (int iulData = _bLen; iulData < s_cNumeMax; iulData++)
                Debug.Assert(rglData[iulData] == 0, "rglData[iulData] == 0", "In AssertValid");
        }
        /*

Usage Example

Esempio n. 1
0
 // Truncate - Truncate the numeric to a specific digit
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public static SqlDecimal Truncate(SqlDecimal n, int position)
 {
     n.AssertValid();
     return Round(n, position, true);
 }
All Usage Examples Of System.Data.SqlTypes.SqlDecimal::AssertValid