Created
January 18, 2010 15:31
-
-
Save anonymous/280098 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text.RegularExpressions; | |
namespace CVS_Ver | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine(MaxVer(new string[] { "1.1", "1.2", "1.3", "1.3.2.1", "1.3.2.3", "1.3.2.4", "1.3.2.5.1", "1.3.4.1", "1.4", "1.5" }, "1.3.0.2")); | |
} | |
static string MaxVer(string[] FileVersions, string BaseVersion) | |
{ | |
string Version = Regex.Replace(BaseVersion,@"(.*)\.0(\.\d+)","$1$2."); | |
string MaxVersion = Version; | |
for (int i = 0; i < FileVersions.Length; i++) | |
if (FileVersions[i].StartsWith(Version) && | |
FileVersions[i].Trim().Length==Version.Length+1 &&//don't search in inner branches | |
String.Compare(FileVersions[i], MaxVersion) == 1) | |
MaxVersion = FileVersions[i]; | |
return MaxVersion; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment