Class MagicNumbers
This class defines constants for commonly used magic numbers. Others are defined in companion class ArrayInfo, while SpecialCharacters defines character representations of the visually ambiguous numbers and letters, for use in place of literals.
Since static classes are implicitly sealed, this class cannot be inherited.
Inheritance
Inherited Members
Namespace: WizardWrx
Assembly: WizardWrx.Common.dll
Syntax
public static class MagicNumbers
Remarks
For ease of access, I promoted the classes that expose only constants to the root of the WizardWrx namespace.
Fields
| Improve this Doc View SourceAPPLICATION_ERROR_MASK
This constant defines the standard APPLICATION_ERROR_MASK bit, which distinguishes application errors from system errors in the status codes returned by Marshal.GetLastWin32Error.
Declaration
public const uint APPLICATION_ERROR_MASK = 536870912U
Field Value
Type | Description |
---|---|
System.UInt32 |
CAPACITY_01KB
Constant for sizing a 1 KB StringBuilder, array, or buffer.
Declaration
public const int CAPACITY_01KB = 1024
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
CAPACITY_02KB
Constant for sizing a 2 KB StringBuilder, array, or buffer.
Declaration
public const int CAPACITY_02KB = 2048
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
CAPACITY_04KB
Constant for sizing a 4 KB StringBuilder, array, or buffer.
Declaration
public const int CAPACITY_04KB = 4096
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
CAPACITY_08KB
Constant for sizing a 8 KB StringBuilder, array, or buffer.
Declaration
public const int CAPACITY_08KB = 8192
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
CAPACITY_10
Use this to set a small capacity on empty List and Dictionary collections.
Declaration
public const int CAPACITY_10 = 10
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
| Improve this Doc View SourceCAPACITY_128
Constant for sizing a 128 unit StringBuilder, array, or buffer.
Declaration
public const int CAPACITY_128 = 128
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
CAPACITY_16
Use this to set a small capacity on empty List and Dictionary collections.
Declaration
public const int CAPACITY_16 = 16
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
| Improve this Doc View SourceCAPACITY_16KB
Constant for sizing a 16 KB StringBuilder, array, or buffer.
Declaration
public const int CAPACITY_16KB = 16384
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
CAPACITY_255
Constant for sizing a 255 unit StringBuilder, array, or buffer.
Declaration
public const int CAPACITY_255 = 255
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
CAPACITY_256
Constant for sizing a 256 unit StringBuilder, array, or buffer.
Declaration
public const int CAPACITY_256 = 256
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
CAPACITY_32KB
Constant for sizing a 32 KB StringBuilder, array, or buffer.
Declaration
public const int CAPACITY_32KB = 32768
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
CAPACITY_4
Use this to set a small capacity on empty List and Dictionary collections.
Declaration
public const int CAPACITY_4 = 4
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
| Improve this Doc View SourceCAPACITY_64KB
Constant for sizing a 64 KB StringBuilder, array, or buffer.
Declaration
public const int CAPACITY_64KB = 65536
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
CAPACITY_8
Use this to set a small capacity on empty List and Dictionary collections.
Declaration
public const int CAPACITY_8 = 8
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
| Improve this Doc View SourceCAPACITY_MAX_PATH
Constant for sizing a MAX_PATH StringBuilder, array, or buffer.
Declaration
public const int CAPACITY_MAX_PATH = 260
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
EMPTY_STRING_LENGTH
Use this constant to document when zero stands for the length of the empty string, or is the lower limit of a string length argument.
Declaration
public const int EMPTY_STRING_LENGTH = 0
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
ERROR_INVALID_CMD_LNE_ARGS
This exit code is reserved for reporting invalid command line arguments.
Declaration
public const int ERROR_INVALID_CMD_LNE_ARGS = 2
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
| Improve this Doc View SourceERROR_RUNTIME
This exit code is reserved for reporting runtime exceptions.
Declaration
public const int ERROR_RUNTIME = 1
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
| Improve this Doc View SourceERROR_SUCCESS
Use this with environment.exit() and other situations when you want to report the default "success" exit code of zero.
Declaration
public const int ERROR_SUCCESS = 0
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
| Improve this Doc View SourceEVENLY_DIVISIBLE
Use this constant with the modulus operator to evaluate whether one integer is evenly divisible by a smaller integer.
Declaration
public const int EVENLY_DIVISIBLE = 0
Field Value
Type | Description |
---|---|
System.Int32 |
Examples
The following example uses the modulus operator to evaluate whether a counter is an even multiple of one hundred, updating a frozen line on the program's console with the new count.
if ( intTotalRows % MagicNumbers.EXACTLY_ONE_HUNDRED == MagicNumbers.EVENLY_DIVISIBLE )
{
fixedConsoleWriter.Write(
@"{0} of {1} records processed" ,
intTotalRows.ToString(NumericFormats.IntegerPerRegSettings ( ) ) ,
intRowsInTable.ToString(NumericFormats.IntegerPerRegSettings ( ) ) );
} // if ( intTotalRows % MagicNumbers.EXACTLY_ONE_NUNDRED == MagicNumbers.ZERO )
See Also
EXACTLY_ONE_BILLION
Use this constant when you need a literal value of exactly one billion.
Declaration
public const int EXACTLY_ONE_BILLION = 1000000000
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
EXACTLY_ONE_HUNDRED
Use this constant when you need a literal value of exactly one hundred.
Declaration
public const int EXACTLY_ONE_HUNDRED = 100
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
EXACTLY_ONE_HUNDRED_MILLION
Use this constant when you need a literal value of exactly one hundred million.
Declaration
public const int EXACTLY_ONE_HUNDRED_MILLION = 100000000
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
EXACTLY_ONE_HUNDRED_MILLION_LONG
Use this constant when you need a long integer literal value of exactly one hundred million.
Declaration
public const long EXACTLY_ONE_HUNDRED_MILLION_LONG = 100000000L
Field Value
Type | Description |
---|---|
System.Int64 |
See Also
EXACTLY_ONE_HUNDRED_THOUSAND
Use this constant when you need a literal value of exactly one hundred thousand.
Declaration
public const int EXACTLY_ONE_HUNDRED_THOUSAND = 1000000
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
EXACTLY_ONE_MILLION
Use this constant when you need a literal value of exactly one million.
Declaration
public const int EXACTLY_ONE_MILLION = 1000000
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
EXACTLY_ONE_THOUSAND
Use this constant when you need a literal value of exactly one thousand.
Declaration
public const int EXACTLY_ONE_THOUSAND = 1000
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
EXACTLY_TEN
Use this constant when you need a literal value of exactly ten.
Declaration
public const int EXACTLY_TEN = 10
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
EXACTLY_TEN_THOUSAND
Use this constant when you need a literal value of exactly ten thousand.
Declaration
public const int EXACTLY_TEN_THOUSAND = 10000
Field Value
Type | Description |
---|---|
System.Int32 |
Remarks
This internal-use literal may as well be public.
See Also
MILLISECONDS_PER_SECOND
Use this constant when you need a literal value of exactly one second worth of milliseconds..
Declaration
public const int MILLISECONDS_PER_SECOND = 1000
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
| Improve this Doc View SourceMINUS_ONE
Use this constant to disambiguate a negative 1 from a positive 1 immediately following a minus sign that is intended to be an operator.
Declaration
public const int MINUS_ONE = -1
Field Value
Type | Description |
---|---|
System.Int32 |
Remarks
This constant is especially useful in an expression that follows any algebraic operator with an operand value of -1.
See Also
MSO_COLLECTION_FIRST_ITEM
Use this integer to start a loop over a one-based collection of Microsoft Office object collections, such as cells in an Excel worksheet.
Declaration
public const int MSO_COLLECTION_FIRST_ITEM = 1
Field Value
Type | Description |
---|---|
System.Int32 |
NUMBER_BASE_DECIMAL
Use this value with Math.Pow to raise ten to a specified power.
Declaration
public const int NUMBER_BASE_DECIMAL = 10
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
| Improve this Doc View SourceNUMBER_BASE_HEXADECIMAL
Use this value with Math.Pow to raise sixteen to a specified power.
Declaration
public const int NUMBER_BASE_HEXADECIMAL = 16
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
| Improve this Doc View SourcePLUS_EIGHT
Eight is the cube of two.
Declaration
public const int PLUS_EIGHT = 8
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
PLUS_FIVE
Five fingers has a normal, fully-equipped human hand.
Declaration
public const int PLUS_FIVE = 5
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
PLUS_FOUR
Two times two equals four, the first integral power of two.
Declaration
public const int PLUS_FOUR = 4
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
PLUS_NINE
Number Nine, number nine, number nine . . .
Declaration
public const int PLUS_NINE = 9
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
PLUS_ONE
Use this constant to disambiguate a numeric value of 1 from a literal upper case I or lower case L, either of which is a legal variable name, and all of which are almost impossible to reiaably distinguish visually in source code.
Declaration
public const int PLUS_ONE = 1
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
PLUS_SEVEN
Number 7, to clearly distinguish it from a letter Z and a numeral 2, which can look a lot like it.
Compare to character constants CHAR_LC_Z and CHAR_UC_Z.
Declaration
public const int PLUS_SEVEN = 7
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
PLUS_SIX
Six fills the gap between five and seven.
Declaration
public const int PLUS_SIX = 6
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
PLUS_THREE
Thres makes a crowd.
Declaration
public const int PLUS_THREE = 3
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
PLUS_TWO
Number 2, to clearly distinguish it from a letter Z and a numeral 7, which can look a lot like it.
Compare to character constants CHAR_LC_Z and CHAR_UC_Z.
Declaration
public const int PLUS_TWO = 2
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
STRING_INDEXOF_NOT_FOUND
Value returned by the IndexOf methods, e. g., of the String class, if the object sought is not found.
Declaration
public const int STRING_INDEXOF_NOT_FOUND = -1
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
| Improve this Doc View SourceSTRING_SUBSTR_BEGINNING
Use with the Substring method of the String class to denote the first character in a string.
Declaration
public const int STRING_SUBSTR_BEGINNING = 0
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
| Improve this Doc View SourceTICKS_PER_1_DAY
There are 864,000,000,000 ticks in one calendar day.
Use this constant to construct a TimeSpan of the corresponding length (value) by way of its one-argument constructor, or to increase or decrease the value of a time span by the corresponding amount by way of its one-argument method.
Declaration
public const long TICKS_PER_1_DAY = 864000000000L
Field Value
Type | Description |
---|---|
System.Int64 |
See Also
TICKS_PER_1_HOUR
There are 36,000,000,000 ticks in one hour.
Use this constant to construct a TimeSpan of the corresponding length (value) by way of its one-argument constructor, or to increase or decrease the value of a time span by the corresponding amount by way of its one-argument method.
Declaration
public const long TICKS_PER_1_HOUR = 36000000000L
Field Value
Type | Description |
---|---|
System.Int64 |
See Also
TICKS_PER_1_MILLISECOND
There are 10,000 ticks in one millisecond.
Use this constant to construct a TimeSpan of the corresponding length (value) by way of its one-argument constructor, or to increase or decrease the value of a time span by the corresponding amount by way of its one-argument method.
Declaration
public const long TICKS_PER_1_MILLISECOND = 10000L
Field Value
Type | Description |
---|---|
System.Int64 |
See Also
TICKS_PER_1_MINUTE
There are 600,000,000 ticks in one minute.
Use this constant to construct a TimeSpan of the corresponding length (value) by way of its one-argument constructor, or to increase or decrease the value of a time span by the corresponding amount by way of its one-argument method.
Declaration
public const long TICKS_PER_1_MINUTE = 600000000L
Field Value
Type | Description |
---|---|
System.Int64 |
See Also
TICKS_PER_1_SECOND
There are 10,000,000 ticks in one second.
Use this constant to construct a TimeSpan of the corresponding length (value) by way of its one-argument constructor, or to increase or decrease the value of a time span by the corresponding amount by way of its one-argument method.
Declaration
public const long TICKS_PER_1_SECOND = 10000000L
Field Value
Type | Description |
---|---|
System.Int64 |
See Also
TICKS_PER_1_WEEK
There are 6,048,000,000,000 ticks in one calendar week.
Use this constant to construct a TimeSpan of the corresponding length (value) by way of its one-argument constructor, or to increase or decrease the value of a time span by the corresponding amount by way of its one-argument method.
Declaration
public const long TICKS_PER_1_WEEK = 6048000000000L
Field Value
Type | Description |
---|---|
System.Int64 |
See Also
TICKS_PER_23_59_00
There are 863,400,000,000 ticks in one calendar day less one minute.
Use this constant to construct a TimeSpan of the corresponding length (value) by way of its one-argument constructor, or to increase or decrease the value of a time span by the corresponding amount by way of its one-argument method.
Declaration
public const long TICKS_PER_23_59_00 = 863400000000L
Field Value
Type | Description |
---|---|
System.Int64 |
See Also
TICKS_PER_23_59_59
There are 863,990,000,000 ticks in one calendar day less one second.
Use this constant to construct a TimeSpan of the corresponding length (value) by way of its one-argument constructor, or to increase or decrease the value of a time span by the corresponding amount by way of its one-argument method.
Declaration
public const long TICKS_PER_23_59_59 = 863990000000L
Field Value
Type | Description |
---|---|
System.Int64 |
See Also
TICKS_PER_SECOND
There are ten million ticks of one hundred nanoseconds each in one second.
BREAKING CHANGE: Prior to version 7.14, this value was understated by a factor of one thousand.
Use this constant to construct a TimeSpan of the corresponding length (value) by way of its one-argument constructor, or to increase or decrease the value of a time span by the corresponding amount by way of its one-argument method.
Declaration
public const int TICKS_PER_SECOND = 10000000
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
| Improve this Doc View SourceUNC_PREFIX_START_LEN
A UNC prefix has this many characters.
Declaration
public const int UNC_PREFIX_START_LEN = 2
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
| Improve this Doc View SourceUNC_PREFIX_START_POS
A UNC prefix starts here at this character position.
Declaration
public const int UNC_PREFIX_START_POS = 1
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
| Improve this Doc View SourceZERO
Constant equivalent to integer value of zero, to disambiguate zero literal values in code.
Compare to character constants CHAR_LC_O and CHAR_UC_O.
Declaration
public const int ZERO = 0
Field Value
Type | Description |
---|---|
System.Int32 |