Class SemanticVersion
Represents a semantic version number.
public class SemanticVersion : IEquatable<SemanticVersion>, IComparable<SemanticVersion>
- Inheritance
-
SemanticVersion
- Implements
- Inherited Members
Constructors
SemanticVersion(int, int, int)
Initializes a new instance of the SemanticVersion class.
public SemanticVersion(int major, int minor, int patch)
Parameters
SemanticVersion(int, int, int, string)
Initializes a new instance of the SemanticVersion class.
public SemanticVersion(int major, int minor, int patch, string preRelease)
Parameters
major
intThe major version.
minor
intThe minor version.
patch
intThe patch version.
preRelease
stringThe pre release version.
Properties
Major
Gets the major version.
public int Major { get; }
Property Value
- int
The major version.
Minor
Gets the minor version.
public int Minor { get; }
Property Value
- int
The minor version.
Patch
Gets the patch version.
public int Patch { get; }
Property Value
- int
The patch version.
PreRelease
Gets the pre release version.
public string PreRelease { get; }
Property Value
- string
The pre release version.
Methods
CompareTo(SemanticVersion)
public int CompareTo(SemanticVersion other)
Parameters
other
SemanticVersion
Returns
Equals(SemanticVersion)
public bool Equals(SemanticVersion other)
Parameters
other
SemanticVersion
Returns
Equals(object)
public override bool Equals(object obj)
Parameters
obj
object
Returns
GetHashCode()
public override int GetHashCode()
Returns
Parse(string)
Parses a string representation of a semantic version.
public static SemanticVersion Parse(string value)
Parameters
value
stringThe string value to parse.
Returns
- SemanticVersion
A semantic version.
ToString()
public override string ToString()
Returns
TryParse(string, out SemanticVersion)
Tries to parse a string representation of a semantic version.
public static bool TryParse(string value, out SemanticVersion result)
Parameters
value
stringThe string value to parse.
result
SemanticVersionThe result.
Returns
- bool
True if the string representation was parsed successfully; otherwise false.
Operators
operator ==(SemanticVersion, SemanticVersion)
Determines whether two specified semantic versions have the same value.
public static bool operator ==(SemanticVersion a, SemanticVersion b)
Parameters
a
SemanticVersionThe first semantic version to compare, or null.
b
SemanticVersionThe second semantic version to compare, or null.
Returns
- bool
True if the value of a is the same as the value of b; otherwise false.
operator >(SemanticVersion, SemanticVersion)
Determines whether the first specified SemanticVersion is greater than the second specified SemanticVersion.
public static bool operator >(SemanticVersion a, SemanticVersion b)
Parameters
a
SemanticVersionThe first semantic version to compare, or null.
b
SemanticVersionThe second semantic version to compare, or null.
Returns
- bool
True if the value of a is greater than b; otherwise false.
operator >=(SemanticVersion, SemanticVersion)
Determines whether the first specified SemanticVersion is greater than or equal to the second specified SemanticVersion.
public static bool operator >=(SemanticVersion a, SemanticVersion b)
Parameters
a
SemanticVersionThe first semantic version to compare, or null.
b
SemanticVersionThe second semantic version to compare, or null.
Returns
- bool
True if the value of a is greater than or equal to b; otherwise false.
operator !=(SemanticVersion, SemanticVersion)
Determines whether two specified semantic versions have different values.
public static bool operator !=(SemanticVersion a, SemanticVersion b)
Parameters
a
SemanticVersionThe first semantic version to compare, or null.
b
SemanticVersionThe second semantic version to compare, or null.
Returns
- bool
True if the value of a is different from the value of b; otherwise false.
operator <(SemanticVersion, SemanticVersion)
Determines whether the first specified SemanticVersion is less than the second specified SemanticVersion.
public static bool operator <(SemanticVersion a, SemanticVersion b)
Parameters
a
SemanticVersionThe first semantic version to compare, or null.
b
SemanticVersionThe second semantic version to compare, or null.
Returns
- bool
True if the value of a is less than b; otherwise false.
operator <=(SemanticVersion, SemanticVersion)
Determines whether the first specified SemanticVersion is less than or equal to the second specified SemanticVersion.
public static bool operator <=(SemanticVersion a, SemanticVersion b)
Parameters
a
SemanticVersionThe first semantic version to compare, or null.
b
SemanticVersionThe second semantic version to compare, or null.
Returns
- bool
True if the value of a is less than or equal to b; otherwise false.