Primitively Primitively
Primitively Primitively
DocFX + Singulink = ♥

Search Results for

    Class DecimalAttribute

    This attribute should be used on a partial record struct to source generate a Primitively IDecimal type that encapsulates a decimal value.

    Inheritance
    object
    Attribute
    PrimitiveAttribute
    NumericAttribute
    DecimalAttribute
    Inherited Members
    NumericAttribute.Maximum
    NumericAttribute.Minimum
    PrimitiveAttribute.ImplementIValidatableObject
    Namespace: Primitively
    Assembly: Primitively.Abstractions.dll
    Syntax
    [AttributeUsage(AttributeTargets.Struct, Inherited = false, AllowMultiple = false)]
    public sealed class DecimalAttribute : NumericAttribute
    Examples

    These examples show how to use the Decimal attribute to source generate a Primitively IDecimal type.

    [Decimal]
    public partial record struct Example;
    
    [Decimal(3)]
    public partial record struct Example;

    Constructors

    DecimalAttribute()

    Initializes a new instance of the DecimalAttribute class.

    Declaration
    public DecimalAttribute()

    DecimalAttribute(int)

    Initializes a new instance of the DecimalAttribute class with the specified number of fractional digits.

    Declaration
    public DecimalAttribute(int digits)
    Parameters
    Type Name Description
    int digits

    The number of fractional digits in the value of the source generated Primitively IDecimal type.

    DecimalAttribute(int, MidpointRounding)

    Initializes a new instance of the DecimalAttribute class with the specified number of fractional digits and rounding mode.

    Declaration
    public DecimalAttribute(int digits, MidpointRounding mode)
    Parameters
    Type Name Description
    int digits

    The number of fractional digits in the value of the source generated Primitively IDecimal type.

    MidpointRounding mode

    The rounding specification for how to round value of the source generated Primitively IDecimal type if it is midway between two other numbers.

    Properties

    Digits

    Gets the number of fractional digits in the value of the source generated Primitively IDecimal type.

    Declaration
    public int Digits { get; }
    Property Value
    Type Description
    int
    Remarks

    Valid values are: -1 to 28. Values above 28 will default to: -1. Values below -1 will default to: -1. A value of -1 will result in: no rounding.

    Mode

    Gets the rounding specification for how to round value of the source generated Primitively IDecimal type if it is midway between two other numbers.

    Declaration
    public MidpointRounding Mode { get; }
    Property Value
    Type Description
    MidpointRounding
    Remarks

    If the value of Digits is -1, this property will have no effect.

    © Electronic Hands. All rights reserved.