public static string RomanToInt(string Roman)
{
int converted = 0;
if (Roman.Contains("IX"))
{
converted += 9;
Roman = Roman.Replace("IX", "");
}
if (Roman.Contains("IV"))
{
converted += 4;
Roman = Roman.Replace("IV", "");
}
if (Roman.Contains("XL"))
{
converted += 40;
Roman = Roman.Replace("XL", "");
}
if (Roman.Contains("XC"))
{
converted += 90;
Roman = Roman.Replace("XC", "");
}
converted += (Regex.Matches(Roman, "C").Count * 100);
converted += (Regex.Matches(Roman, "L").Count * 50);
converted += (Regex.Matches(Roman, "X").Count * 10);
converted += (Regex.Matches(Roman, "V").Count * 5);
converted += Regex.Matches(Roman, "I").Count;
string convertedString = converted.ToString();
if (converted < 10)
convertedString = 0 + convertedString;
return convertedString;
}