5,451 questions
Check an approach:
string text = @"
save[0] = 0
generate_num[0] = 1
";
string result = Regex.Replace( text, @"(?<=^\s*.+?=\s*)(\d+)", "25" );
To increase the found number:
string result = Regex.Replace( text, @"(?<=^\s*.+?=\s*)(\d+)", m => ( int.Parse( m.Value ) + 2 ).ToString( ) );
To read and write the file, use File.ReadAllText and File.WriteAllText.