public static void Main()
Console.WriteLine(TestString("MD00494", 5));
Console.WriteLine(TestString("XXX123YYY456"));
Console.WriteLine(TestString("SD50MRF999", 3));
Console.WriteLine(TestString("SD50MRF9", 3));
public static string TestString(string input, int minNumericalCharacters = 1)
return input + " : " + IncrementStringEnd(input, minNumericalCharacters);
public static string IncrementStringEnd(string name, int minNumericalCharacters = 1)
var prefix = System.Text.RegularExpressions.Regex.Match(name, @"\d+$");
var capture = prefix.Captures[0];
int number = int.Parse(capture.Value) + 1;
name = name.Remove(capture.Index, capture.Length) + number.ToString("D" + minNumericalCharacters);
namespace RoslynCompileSample
public double Top{ get; set; }
public double Bottom{ get; set; }
public double Left{ get; set; }
public double Right{ get; set; }
public double CentreX{ get; set; }
public double CentreY{ get; set; }
public void Main(string message)
StackPanel StackPanel1 = new StackPanel();
StackPanel StackPanel2 = new StackPanel();
StackPanel StackPanel3 = new StackPanel();
StackPanel StackPanel4 = new StackPanel();