Specificity Struct

The specificity of a selector (https://drafts.csswg.org/selectors-4/#specificity-rules).

public readonly struct Specificity : IComparable<Specificity>, IEquatable<Specificity>
Implements

Constructors

NameDescription
Specificity(int, int, int)The specificity of a selector (https://drafts.csswg.org/selectors-4/#specificity-rules).

Specificity(int, int, int)

The specificity of a selector (https://drafts.csswg.org/selectors-4/#specificity-rules).

public Specificity(int A, int B, int C)

Parameters

A int
The number of ID selectors.
B int
The number of class selectors, attribute selectors and pseudo-classes.
C int
The number of type selectors and pseudo-elements.

Properties

NameDescription
AThe number of ID selectors.
BThe number of class selectors, attribute selectors and pseudo-classes.
CThe number of type selectors and pseudo-elements.

The number of ID selectors.

public int A { get; init; }

Property value

int

The number of class selectors, attribute selectors and pseudo-classes.

public int B { get; init; }

Property value

int

The number of type selectors and pseudo-elements.

public int C { get; init; }

Property value

int

Methods

NameDescription
CompareTo(Specificity)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.
Deconstruct(int, int, int)
Equals(Specificity)
Equals(object)
GetHashCode()
Max(Specificity, Specificity)Returns the greater of the two specificities.
ToString()Returns the specificity as "(A, B, C)".

CompareTo(Specificity)

Selector.cs

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.

public int CompareTo(Specificity other)

Parameters

other Specificity
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:

ValueMeaning
Less than zeroThis instance precedes other in the sort order.
ZeroThis instance occurs in the same position in the sort order as other.
Greater than zeroThis instance follows other in the sort order.

Deconstruct(int, int, int)

public void Deconstruct(out int A, out int B, out int C)

Parameters

A int
B int
C int

No documentation is available.

Equals overloads

Equals(Specificity)

public bool Equals(Specificity other)
Parameters
other Specificity
Returns

bool

No documentation is available.

Equals(object)

public override bool Equals(object obj)
Parameters
obj object
Returns

bool

No documentation is available.

GetHashCode()

public override int GetHashCode()

Returns

int

No documentation is available.

Max(Specificity, Specificity)

Selector.cs

Returns the greater of the two specificities.

public static Specificity Max(Specificity left, Specificity right)

Parameters

left Specificity
right Specificity

Returns

Specificity

ToString()

Selector.cs

Returns the specificity as "(A, B, C)".

public override string ToString()

Returns

string

Operators

NameDescription
operator +(Specificity, Specificity)Returns the component-wise sum of the two specificities.
operator ==(Specificity, Specificity)
operator >(Specificity, Specificity)Returns whether the left specificity is greater than the right specificity.
operator >=(Specificity, Specificity)Returns whether the left specificity is greater than or equal to the right specificity.
operator !=(Specificity, Specificity)
operator <(Specificity, Specificity)Returns whether the left specificity is lower than the right specificity.
operator <=(Specificity, Specificity)Returns whether the left specificity is lower than or equal to the right specificity.

operator +(Specificity, Specificity)

Selector.cs

Returns the component-wise sum of the two specificities.

public static Specificity operator +(Specificity left, Specificity right)

Parameters

left Specificity
right Specificity

Returns

Specificity

operator ==(Specificity, Specificity)

public static bool operator ==(Specificity left, Specificity right)

Parameters

left Specificity
right Specificity

Returns

bool

No documentation is available.

operator >(Specificity, Specificity)

Selector.cs

Returns whether the left specificity is greater than the right specificity.

public static bool operator >(Specificity left, Specificity right)

Parameters

left Specificity
right Specificity

Returns

bool

operator >=(Specificity, Specificity)

Selector.cs

Returns whether the left specificity is greater than or equal to the right specificity.

public static bool operator >=(Specificity left, Specificity right)

Parameters

left Specificity
right Specificity

Returns

bool

operator !=(Specificity, Specificity)

public static bool operator !=(Specificity left, Specificity right)

Parameters

left Specificity
right Specificity

Returns

bool

No documentation is available.

operator <(Specificity, Specificity)

Selector.cs

Returns whether the left specificity is lower than the right specificity.

public static bool operator <(Specificity left, Specificity right)

Parameters

left Specificity
right Specificity

Returns

bool

operator <=(Specificity, Specificity)

Selector.cs

Returns whether the left specificity is lower than or equal to the right specificity.

public static bool operator <=(Specificity left, Specificity right)

Parameters

left Specificity
right Specificity

Returns

bool