C♯ Snippets

Download file to string

WebClient client = new WebClient();
string downloadString = client.DownloadString("http://www.gooogle.com");

Replace a reg-ex match

var text = "four score and seven years ago";
var rx = new Regex(@"[a-z]{5}");
Func<Match, String> fun = match => match.Groups[0].Value.ToUpper();
var result = rx.Replace(text, new MatchEvaluator(fun));
System.Console.WriteLine(result); //> four SCORE and SEVEN YEARS ago