Let's suppose I have such "helper" methods used by some object.
private int MatchRegex(string regex, string input)
{
var match = Regex.Match(input, regex);
return match.Success ? Convert.ToInt32(match.Groups[1].Value) : 0;
}
private string Exec(string arguments, string path = "", bool oneLine = false)
{
var p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
if (path != "")
p.StartInfo.WorkingDirectory = path;
p.StartInfo.FileName = "binary.exe";
p.StartInfo.Arguments = arguments;
p.Start();
string output = oneLine ? p.StandardOutput.ReadLine() : p.StandardOutput.ReadToEnd();
p.WaitForExit();
return output;
}
Which would you choose to move out them: another class, partial class or extension methods? And why?