System.Data.SqlClient.SqlParameter.StringSize C# (CSharp) Méthode

StringSize() private static méthode

private static StringSize ( object value, bool isSqlType ) : int
value object
isSqlType bool
Résultat int
        private static int StringSize(object value, bool isSqlType)
        {
            if (isSqlType)
            {
                Debug.Assert(!((INullable)value).IsNull, "Should not call StringSize on null values");
                if (value is SqlString)
                {
                    return ((SqlString)value).Value.Length;
                }
                if (value is SqlChars)
                {
                    return ((SqlChars)value).Value.Length;
                }
            }
            else
            {
                string svalue = (value as string);
                if (null != svalue)
                {
                    return svalue.Length;
                }
                char[] cvalue = (value as char[]);
                if (null != cvalue)
                {
                    return cvalue.Length;
                }
                if (value is char)
                {
                    return 1;
                }
            }

            // Didn't match, unknown size
            return 0;
        }