4 . 0-255 (, , , ), .
8.10.0.0, 9.0.0.0 (81 000 > 9000).
public static int VersionToInt( string version ) {
var versionParts = version.Split( '.' );
if ( versionParts.Length != 4 ) {
throw new ArgumentException( "Invalid version number; invalid number of version parts, expected 4 (major.minor.build.revision)",
"version" );
}
byte major, minor, build, revision;
if ( !byte.TryParse( versionParts[0], out major ) ) {
throw new ArgumentException( "Invalid version number; invalid major number",
"version" );
}
if ( !byte.TryParse( versionParts[1], out minor ) ) {
throw new ArgumentException( "Invalid version number; invalid minor number",
"version" );
}
if ( !byte.TryParse( versionParts[2], out build ) ) {
throw new ArgumentException( "Invalid version number; invalid build number",
"version" );
}
if ( !byte.TryParse( versionParts[3], out revision ) ) {
throw new ArgumentException( "Invalid version number; invalid revision number",
"version" );
}
var versionInteger = 0;
versionInteger |= major << 24;
versionInteger |= minor << 16;
versionInteger |= build << 8;
versionInteger |= revision;
return versionInteger;
}