Skip to content

Instantly share code, notes, and snippets.

Created January 18, 2010 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/280098 to your computer and use it in GitHub Desktop.
Save anonymous/280098 to your computer and use it in GitHub Desktop.
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