Monday, June 13, 2011

Replace space with another string


string str="good morning";
Regex rgx = new Regex("\\s+");
str = rgx.Replace(str, "%20");

Formatting Date Time in C#

DateTime time = DateTime.Now;
string format = "MMM ddd d HH:mm yyyy";
Console.WriteLine(time.ToString(format));