Class Percentage
- Namespace
- ElectricDrill.AstraRpgFramework.Utils
- Assembly
- com.electricdrill.astra-rpg-framework.Runtime.dll
The Percentage class represents a percentage value and provides various operators and conversions.
Implicit long to Percentage value conversion is available. To express a 100% value, use 100L.
Implicit Percentage to double conversion is available. When doing so, the percentage is automatically
divided by 100.
[Serializable]
public class Percentage
- Inheritance
-
objectPercentage
Constructors
Percentage(long)
Initializes a new instance of the Percentage class with the specified value. To express a 100% value, use 100L.
public Percentage(long value)
Parameters
valuelongThe value of the percentage.
Methods
CompareTo(Percentage)
Compares the current Percentage instance with another Percentage instance.
public int CompareTo(Percentage other)
Parameters
otherPercentageThe other percentage to compare to.
Returns
- int
An integer indicating the relative order of the percentages.
ToString()
Returns a string representation of the percentage value.
public override string ToString()
Returns
- string
A string representing the percentage value.
Operators
operator +(Percentage, Percentage)
Overrides the + operator to add two Percentage instances.
public static Percentage operator +(Percentage a, Percentage b)
Parameters
aPercentageThe first percentage.
bPercentageThe second percentage.
Returns
- Percentage
A new Percentage instance representing the sum.
explicit operator long(Percentage)
Explicit conversion from Percentage to long. The conversion does not divide the value by 100.
public static explicit operator long(Percentage percentage)
Parameters
percentagePercentageThe percentage to convert.
Returns
- long
implicit operator double(Percentage)
Implicit conversion from Percentage to double. The conversion automatically divides the value by 100.
public static implicit operator double(Percentage percentage)
Parameters
percentagePercentageThe percentage to convert.
Returns
- double
implicit operator Percentage(long)
Implicit conversion from long to Percentage. To express a 100% value, use 100L.
public static implicit operator Percentage(long value)
Parameters
valuelongThe value to convert.
Returns
operator -(Percentage, Percentage)
Overrides the - operator to subtract one Percentage from another.
public static Percentage operator -(Percentage a, Percentage b)
Parameters
aPercentageThe first percentage.
bPercentageThe second percentage.
Returns
- Percentage
A new Percentage instance representing the difference.
operator -(Percentage)
Overrides the unary - operator to negate a Percentage.
public static Percentage operator -(Percentage a)
Parameters
aPercentageThe percentage to negate.
Returns
- Percentage
A new Percentage instance representing the negated value.