New to Telerik ReportingStart a free 30-day trial

Unit

Class

Represents a length measurement.

Definition

Namespace:Telerik.Reporting.Charting.Styles

Assembly:Telerik.Reporting.dll

Syntax:

C#
[TypeConverter(typeof(UnitConverter))]
public class Unit

Inheritance: objectUnit

Constructors

Creates a class instance

C#
public Unit()

Initializes a new instance of the Unit with the specified double precision floating point number and the target type

C#
public Unit(double value, UnitType type)
Parameters:valuedouble

A double precision floating point number that represents the length of the Unit in pixels.

typeUnitType

Unit type

Initializes a new instance of the Unit with the specified double precision floating point number.

C#
public Unit(double value)
Parameters:valuedouble

A double precision floating point number that represents the length of the Unit in pixels.

Initializes a new instance of the Unit with the specified double precision floating point number and the target type.

C#
public Unit(float value, UnitType type)
Parameters:valuefloat

A float precision floating point number that represents the length of the Unit in pixels.

typeUnitType

Unit type (Pixel / Percentage)

Initializes a new instance of the Unit with the specified double precision floating point number.

C#
public Unit(float value)
Parameters:valuefloat

A float precision floating point number that represents the length of the Unit in pixels.

Initializes a new instance of the Unit with the specified 32-bit signed integer and the target type

C#
public Unit(int value, UnitType type)
Parameters:valueint

A 32-bit signed integer that represents the length of the Unit in pixels.

typeUnitType

Unit type

Initializes a new instance of the Unit with the specified 32-bit signed integer.

C#
public Unit(int value)
Parameters:valueint

A 32-bit signed integer that represents the length of the Unit in pixels.

Initializes a new instance of the Unit with the specified length.

C#
public Unit(string value, CultureInfo culture)
Parameters:valuestring

A string that represents the length of the Unit.

cultureCultureInfo

CultureInfo

Initializes a new instance of the Unit with the specified length.

C#
public Unit(string value)
Parameters:valuestring

A string that represents the length of the Unit.

Creates a class instance

C#
public Unit(UnitType type)
Parameters:typeUnitType

UnitType specifies the target Unit type

Fields

Represents an empty Unit. This field is read-only.

C#
public static readonly Unit Empty

Properties

Gets whether Unit is empty

C#
public bool IsEmpty { get; }

Gets or sets the unit type of the Unit.

C#
public UnitType Type { get; set; }

Value

float

Gets or sets the length of the Unit.

C#
public float Value { get; set; }

Methods

Compares this Unit with the specified object.

C#
public override bool Equals(object obj)
Parameters:objobject

The specified object for comparison.

Returns:

bool

true if the Unit that this method is called from is equal to the specified object; otherwise, false.

Overrides: object.Equals(object)

Returns a hash code for this Unit.

C#
public override int GetHashCode()
Returns:

int

Hash code

Overrides: object.GetHashCode()

C#
public static Unit Parse(string s, CultureInfo culture)
Parameters:sstringcultureCultureInfoReturns:

Unit

Converts the specified string to a Unit.

C#
public static Unit Parse(string s)
Parameters:sstring

The string to convert.

Returns:

Unit

A Unit that represents the specified string.

Creates a Unit of type Percentage from the specified double-precision floating-point number.

C#
public static Unit Percentage(double n)
Parameters:ndouble

A double-precision floating-point number that represents the length of the Unit

Returns:

Unit

A Unit of type Percentage that represents the length specified by the double-precision floating-point number.

Creates a Unit of type Pixel from the specified 32-bit signed integer.

C#
public static Unit Pixel(float n)
Parameters:nfloat

A 32-bit signed integer that represents the length of the Unit.

Returns:

Unit

A Unit of type Pixel that represents the length specified by the n parameter.

Base ToString override

C#
public override string ToString()
Returns:

string

String representation of the Unit instance

Overrides: object.ToString()

Base ToString override

C#
public string ToString(CultureInfo culture)
Parameters:cultureCultureInfo

CultureInfo

Returns:

string

String representation of the Unit instance

Operators

Implicitly creates a Unit of type Pixel from the specified float.

C#
public static implicit operator Unit(float n)
Parameters:nfloat

A float that represents the length of the Unit.

Returns:

Unit

A Unit of type Pixel that represents the specified by the n parameter.

Compares two Unit objects to determine whether they are not equal.

C#
public static bool operator !=(Unit left, Unit right)
Parameters:leftUnit

The Unit on the left side of the operator.

rightUnit

The Unit on the right side of the operator.

Returns:

bool

true if the Unit objects are not equal; otherwise, false.

Compares two Unit objects to determine whether they are equal.

C#
public static bool operator ==(Unit left, Unit right)
Parameters:leftUnit

The Unit on the left side of the operator.

rightUnit

The Unit on the right side of the operator.

Returns:

bool

true if both Unit objects are equal; otherwise, false.