If I have a version number that has 5 digits such as "1.0.420.50.0", how could I truncate this number (and other version numbers like "1.0.512.500.0") to only 4 digits? "1.0.420.50.0" --> "1.0.420.50"
I would prefer to use an array but any other methods work too! Thanks for any advice in advance!
I haven't programmed in c# in a while so the syntax may be off. If the versioning can be more than six digits, you won't want a method that relies on removing the last digit. Instead just take the first four version numbers.
String version = "1.0.420.50.0";
String [] versionArray = version.Split(".");
var newVersion = string.Join(".", versionArray.Take(4));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With