public Version IncrementVersion()
{
var random = new Random();
//for demonstration purposes - this should come as a parameter
var version = new Version(random.Next(0, 10), random.Next(0, 10), random.Next(0, 10), random.Next(0, 10));
var versionComponents = version.ToString().Split('.');
int.TryParse(versionComponents?.LastOrDefault(), out int lastVersionComponent);
var incrementedVersion = new Version(version.Major, version.Minor, version.Build, ++lastVersionComponent);
Console.WriteLine($"original version: [{version}] incremented version: [{incrementedVersion}]");
return incrementedVersion;
}
Keeping track of interesting places I put my feet on in the software development world.
Search This Blog
Sunday, December 5, 2021
C# method to increment version object
Subscribe to:
Posts (Atom)