Table of Contents

Class PhysicalValue

Namespace
VirtualLabAPI.Core.Numerics
Assembly
VirtualLabAPI.dll

Class for a double value with a physical unit.

[Serializable]
public class PhysicalValue : PhysicalValueBase, IEquatable<IObjectBase>, ISerializable, IDeserializationCallback, ICloneable, IFormattable, IComparable<PhysicalValue>
Inheritance
ObjectBase
SerializableObjectBase
ManualSerialization
PhysicalValue
Implements
IEquatable<IObjectBase>
Inherited Members

Constructors

PhysicalValue(double, MeasuredQuantity)

Default constructor.

public PhysicalValue(double value, MeasuredQuantity measuredQuantity)

Parameters

value double

The value of the PhysicalValue.

measuredQuantity MeasuredQuantity

The measured quantity of the physical value (e.g. length).

PhysicalValue(double, MeasuredQuantity, string)

Constructor with a comment string.

public PhysicalValue(double value, MeasuredQuantity measuredQuantity, string comment)

Parameters

value double

The value of the PhysicalValue.

measuredQuantity MeasuredQuantity

The measured quantity of the physical value (e.g. length).

comment string

A comment specifying what the PhysicalValue actually is.

PhysicalValue(PhysicalValue)

Copy constructor.

public PhysicalValue(PhysicalValue physicalValue)

Parameters

physicalValue PhysicalValue

PhysicalValue to copy.

Properties

Value

The value of the PhysicalValue.

public virtual double Value { get; set; }

Property Value

double

Methods

Clone()

Overridden Clone function

public override object Clone()

Returns

object

The cloned object.

CompareTo(PhysicalValue)

Compares the current physical value with another physical value by comparing first the physical property, then the comment and then the actual value.

public int CompareTo(PhysicalValue other)

Parameters

other PhysicalValue

A physical value to compare with this physical value.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has the following meanings: Value less than zero: This object is less than the other parameter. Zero: This object is equal to other. Greater than zero: This object is greater than other.

Equals(object, EqualityIntent)

Overridden Equals functionality.

public override bool Equals(object obj, EqualityIntent equalityIntent)

Parameters

obj object

The object to compare for equality.

equalityIntent EqualityIntent

Defines what kind of equality you want to check when comparing two objects, for example all values or physical equality.

Returns

bool

true: The objects are equal. false: The objects are not equal.

GetHashCode()

Gets a hash code.

public override int GetHashCode()

Returns

int

The sum of the hash codes of the three properties Value, PhysicalProperty and Comment.

ToString()

Overridden ToString function. The PhysicalValue is formatted like "1 nm".

public override string ToString()

Returns

string

The formatted value.

ToString(int)

Overridden ToString function. The PhysicalValue is formatted like "1 nm".

public override string ToString(int significantDigits)

Parameters

significantDigits int

The number of significant digits.

Returns

string

The formatted value.

ToString(string, IFormatProvider)

Overridden ToString function provided by the IFormattable interface. Returns a string that represents this instance.

public override string ToString(string format, IFormatProvider formatProvider = null)

Parameters

format string

The format. "U" or an empty string means that the string is formatted with units (e.g. "1 nm"). "G" means that the string is formatted without units (e.g. "1e-9"). "F" means that the string is formatted as "{Comment} of {Value with units}" (e.g. "wavelength of 300 nm").
In all cases you can add a number to specify the number of digits that shall be used. E.g. "U3" results in "1.23 nm", while "U4" results in "1.234 nm". You can add further formatting commands after a comma, but these are ignored. This behavior ensures that the same formatting strings can be used for both PhysicalValue and PhysicalValueComplex.
For any other string the ToString(format, formatProvider) of the Value is used.

formatProvider IFormatProvider

Optional culture specific format provider used for formatting the value (if format is not "U" or "F").

Returns

string

A string that represents this instance.

Operators

operator ==(PhysicalValue, PhysicalValue)

Compares two PhysicalValue for equality. The comparison will be done by comparing the values, units, and comments, respectively.

public static bool operator ==(PhysicalValue value1, PhysicalValue value2)

Parameters

value1 PhysicalValue

First PhysicalValue object to compare.

value2 PhysicalValue

Second PhysicalValue object to compare.

Returns

bool

Returns true if the two objects are equal.

operator !=(PhysicalValue, PhysicalValue)

Compares two PhysicalValue for inequality. The comparison will be done by comparing the values, units, and comments, respectively.

public static bool operator !=(PhysicalValue value1, PhysicalValue value2)

Parameters

value1 PhysicalValue

First PhysicalValue object to compare.

value2 PhysicalValue

Second PhysicalValue object to compare.

Returns

bool

Returns true if the two objects are unequal.