Definition
Assembly: CloudNimble.DotNetDocs.Tools.dll Namespace: CloudNimble.DotNetDocs.Tools.Models Inheritance: System.ObjectSyntax
Summary
Represents a simplified NuGet version for comparison purposes.Remarks
This class provides basic semantic versioning support with major, minor, patch, and prerelease components. It implements IComparable`1 to allow version comparisons, where stable versions are considered greater than prerelease versions with the same major.minor.patch numbers.Constructors
.ctor
Initializes a new instance of the NuGetVersion class from a version string.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
version | string | The version string to parse (e.g., “1.0.0” or “1.0.0-preview.1”). |
Remarks
The version string should be in the format “major.minor.patch” or “major.minor.patch-prerelease”. If any component cannot be parsed, it defaults to 0..ctor Inherited
Inherited from
objectSyntax
Properties
IsPrerelease
Gets a value indicating whether this version is a prerelease version.Syntax
Property Value
Type:bool
Major
Gets the major version component.Syntax
Property Value
Type:int
Minor
Gets the minor version component.Syntax
Property Value
Type:int
Patch
Gets the patch version component.Syntax
Property Value
Type:int
Prerelease
Gets the prerelease label, if any.Syntax
Property Value
Type:string?
Methods
CompareTo
Compares the current version to another version.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
other | CloudNimble.DotNetDocs.Tools.Models.NuGetVersion? | The version to compare to. |
Returns
Type:int
A negative value if this version is less than other, zero if they are equal,
or a positive value if this version is greater than other.
Remarks
Version comparison follows semantic versioning rules. Stable versions are considered greater than prerelease versions with the same major.minor.patch numbers. Prerelease versions are compared lexicographically by their prerelease labels.Equals Override
Determines whether the specified object is equal to the current version.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
obj | object? | The object to compare with the current version. |
Returns
Type:bool
true if the specified object is equal to the current version; otherwise, false.
Equals Inherited Virtual
Inherited from
objectSyntax
Parameters
| Name | Type | Description |
|---|---|---|
obj | object? | - |
Returns
Type:bool
Equals Inherited
Inherited from
objectSyntax
Parameters
| Name | Type | Description |
|---|---|---|
objA | object? | - |
objB | object? | - |
Returns
Type:bool
GetHashCode Override
Returns a hash code for the current version.Syntax
Returns
Type:int
A hash code for the current version.
GetHashCode Inherited Virtual
Inherited from
objectSyntax
Returns
Type:int
GetType Inherited
Inherited from
objectSyntax
Returns
Type:System.Type
MemberwiseClone Inherited
Inherited from
objectSyntax
Returns
Type:object
ReferenceEquals Inherited
Inherited from
objectSyntax
Parameters
| Name | Type | Description |
|---|---|---|
objA | object? | - |
objB | object? | - |
Returns
Type:bool
ToString Override
Returns a string representation of the version.Syntax
Returns
Type:string
A string in the format “major.minor.patch” or “major.minor.patch-prerelease”.
ToString Inherited Virtual
Inherited from
objectSyntax
Returns
Type:string?
Related APIs
- System.IComparable<CloudNimble.DotNetDocs.Tools.Models.NuGetVersion>