Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Struct

OfficeLength

OfficeIMO

Namespace
OfficeIMO
Assembly
OfficeIMO.Core
Source revision
e163ccb36643 with working tree changes
Base
ValueType
Implements
IEquatable<OfficeLength> IComparable<OfficeLength> IComparable IFormattable
Modifiers
sealed

A signed document length stored as whole English Metric Units (EMUs).

Inheritance

  • ValueType
  • OfficeLength

Remarks

Fractional EMUs round to nearest, with midpoint ties away from zero. Arithmetic is checked.

Usage

Explore 153 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Returned or exposed by 57

Accepted by parameters 96

Methods

public static OfficeLength Centimeters(double value) #

Creates a length in centimeters (360,000 EMUs per centimeter).

Parameters

value double required
CompareTo 2 overloads
public int CompareTo(OfficeLength other) #

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

Parameters

other OfficeIMO.OfficeLength required
An object to compare with this instance.

Returns

int A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes in the sort order. Zero This instance occurs in the same position in the sort order as . Greater than zero This instance follows in the sort order.
public int CompareTo(object? obj) #

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

Parameters

obj object? required
An object to compare with this instance.

Returns

int A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes in the sort order. Zero This instance occurs in the same position in the sort order as . Greater than zero This instance follows in the sort order.

Exceptions

  • ArgumentException – obj is not the same type as this instance.
public static OfficeLength Emus(long value) #

Creates a length from whole EMUs.

Parameters

value long required
Equals 2 overloads
public bool Equals(OfficeLength other) #

Indicates whether the current object is equal to another object of the same type.

Parameters

other OfficeIMO.OfficeLength required
An object to compare with this object.

Returns

bool true if the current object is equal to the other parameter; otherwise, false.
public override bool Equals(object? obj) #

Indicates whether this instance and a specified object are equal.

Parameters

obj object? required
The object to compare with the current instance.

Returns

bool true if obj and this instance are the same type and represent the same value; otherwise, false.
public override int GetHashCode() #

Returns the hash code for this instance.

Returns

int A 32-bit signed integer that is the hash code for this instance.
public static OfficeLength Inches(double value) #

Creates a length in inches (914,400 EMUs per inch).

Parameters

value double required
public static OfficeLength Millimeters(double value) #

Creates a length in millimeters (36,000 EMUs per millimeter).

Parameters

value double required
public static OfficeLength op_Addition(OfficeLength left, OfficeLength right) #

Adds lengths, throwing on overflow.

Parameters

left OfficeIMO.OfficeLength required
right OfficeIMO.OfficeLength required
public static bool op_Equality(OfficeLength left, OfficeLength right) #

Compares lengths for equality.

Parameters

left OfficeIMO.OfficeLength required
right OfficeIMO.OfficeLength required

Returns

bool
public static bool op_GreaterThan(OfficeLength left, OfficeLength right) #

Compares signed lengths.

Parameters

left OfficeIMO.OfficeLength required
right OfficeIMO.OfficeLength required

Returns

bool
public static bool op_GreaterThanOrEqual(OfficeLength left, OfficeLength right) #

Compares signed lengths.

Parameters

left OfficeIMO.OfficeLength required
right OfficeIMO.OfficeLength required

Returns

bool
public static bool op_Inequality(OfficeLength left, OfficeLength right) #

Compares lengths for inequality.

Parameters

left OfficeIMO.OfficeLength required
right OfficeIMO.OfficeLength required

Returns

bool
public static bool op_LessThan(OfficeLength left, OfficeLength right) #

Compares signed lengths.

Parameters

left OfficeIMO.OfficeLength required
right OfficeIMO.OfficeLength required

Returns

bool
public static bool op_LessThanOrEqual(OfficeLength left, OfficeLength right) #

Compares signed lengths.

Parameters

left OfficeIMO.OfficeLength required
right OfficeIMO.OfficeLength required

Returns

bool
op_Multiply 2 overloads
public static OfficeLength op_Multiply(OfficeLength length, double scalar) #

Multiplies a length by a finite scalar and rounds to whole EMUs.

Parameters

length OfficeIMO.OfficeLength required
scalar double required
public static OfficeLength op_Multiply(double scalar, OfficeLength length) #

Multiplies a length by a finite scalar and rounds to whole EMUs.

Parameters

scalar double required
length OfficeIMO.OfficeLength required
public static OfficeLength op_Subtraction(OfficeLength left, OfficeLength right) #

Subtracts lengths, throwing on overflow.

Parameters

left OfficeIMO.OfficeLength required
right OfficeIMO.OfficeLength required
public static OfficeLength Parse(string value) #

Parses an invariant number and optional pt, cm, mm, in, px or emu suffix. A bare number means points.

Parameters

value string required
public static OfficeLength Pixels(double value) #

Creates a length in pixels at 96 DPI (9,525 EMUs per pixel).

Parameters

value double required
public static OfficeLength Points(double value) #

Creates a length in points (12,700 EMUs per point).

Parameters

value double required
public double ToCentimeters() #

Returns the length in centimeters.

Returns

double
public long ToEmus() #

Returns the whole EMU value.

Returns

long
public long ToHalfPoints() #

Rounds to whole half-points at write time; midpoint ties round away from zero.

Returns

long
public double ToInches() #

Returns the length in inches.

Returns

double
public double ToMillimeters() #

Returns the length in millimeters.

Returns

double
public double ToPixels() #

Returns the length in 96-DPI pixels.

Returns

double
public double ToPoints() #

Returns the length in points.

Returns

double
ToString 3 overloads
public override string ToString() #

Formats in invariant points with up to four decimal places and no trailing zeros.

Returns

string
public string ToString(string? format) #

Formats in the requested unit, using points when the format is empty or G.

Parameters

format string? required

Returns

string
public string ToString(string? format, IFormatProvider? formatProvider) #

Formats using pt, cm, mm, in, px or emu. An empty format or G means points.

Parameters

format string? required
formatProvider System.IFormatProvider? required

Returns

string
public long ToTwips() #

Rounds to whole twips at write time; midpoint ties round away from zero.

Returns

long
public static bool TryParse(string? value, out OfficeLength result) #

Tries to parse an invariant length. Commas, nonfinite values and overflowing lengths are rejected.

Parameters

value string? required
result OfficeIMO.OfficeLength required

Returns

bool

Properties

public static OfficeLength Zero { get; } #

Gets a zero length.