🖥️How to use

How do you use SemanVer?

Using this library is very simple! Just use the SemanVer.Instance namespace in any piece of code you want to use the library, as in: using SemanVer.Instance;

To parse your semantic version string, for example, 1.0.0-alpha1, you must define a variable that has the type of SemVer. Assign a variable so that it calls the SemVer.Parse() version, passing it your version string, like this:

SemVer semVer = SemVer.Parse(version);

Once the parser finishes parsing your semantic version string, it returns a class contains necessary information about your version:

  • Major version (MajorVersion, int)

  • Minor version (MinorVersion, int)

  • Patch version (PatchVersion, int)

  • Pre-Release info (PreReleaseInfo, string)

  • Build metadata (BuildMetadata, string)

As for the equality operators, this class supports the following operators (assuming that SemVer a has version 1.0.0 and SemVer b has version 1.0.1):

  • ==: Checks to see if both SemVer versions are equal.

  • !=: Checks to see if both SemVer versions are opposite to each other.

  • <: Checks to see if a is older than b

  • >: Checks to see if a is newer than b

  • <=: Checks to see if a is older or equal to b

  • >=: Checks to see if a is newer or equal to b

Last updated