Skip to content

Instantly share code, notes, and snippets.

/gist:280098

Created Jan 18, 2010
Embed
What would you like to do?
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
You can’t perform that action at this time.