Class SemVersion
A semantic version, compared per semver 2.0 (build metadata is ignored).
public sealed class SemVersion : IComparable<SemVersion>, IEquatable<SemVersion>
- Inheritance
-
SemVersion
- Implements
- Inherited Members
Constructors
SemVersion(int, int, int, IReadOnlyList<string>?)
public SemVersion(int major, int minor, int patch, IReadOnlyList<string>? prerelease = null)
Parameters
majorintminorintpatchintprereleaseIReadOnlyList<string>
Properties
IsPrerelease
public bool IsPrerelease { get; }
Property Value
Major
public int Major { get; }
Property Value
Minor
public int Minor { get; }
Property Value
Patch
public int Patch { get; }
Property Value
Prerelease
public IReadOnlyList<string> Prerelease { get; }
Property Value
Methods
CompareTo(SemVersion?)
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(SemVersion? other)
Parameters
otherSemVersionAn 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 otherin the sort order.Zero This instance occurs in the same position in the sort order as other.Greater than zero This instance follows otherin the sort order.
Equals(SemVersion?)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(SemVersion? other)
Parameters
otherSemVersionAn object to compare with this object.
Returns
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current object.
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
Parse(string)
public static SemVersion Parse(string text)
Parameters
textstring
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
TryParse(string?, out SemVersion?)
public static bool TryParse(string? text, out SemVersion? version)
Parameters
textstringversionSemVersion
Returns
Operators
operator >(SemVersion, SemVersion)
public static bool operator >(SemVersion a, SemVersion b)
Parameters
aSemVersionbSemVersion
Returns
operator >=(SemVersion, SemVersion)
public static bool operator >=(SemVersion a, SemVersion b)
Parameters
aSemVersionbSemVersion
Returns
operator <(SemVersion, SemVersion)
public static bool operator <(SemVersion a, SemVersion b)
Parameters
aSemVersionbSemVersion
Returns
operator <=(SemVersion, SemVersion)
public static bool operator <=(SemVersion a, SemVersion b)
Parameters
aSemVersionbSemVersion