导航

c#常用函数(不断更新)

Posted on 2010-05-03 08:40  lilin  阅读(376)  评论(0编辑  收藏  举报

Windows 服务程序根目录

System.AppDomain.CurrentDomain.BaseDirectory

 

20100428165421转换为2010-04-28 16:54:21

DateTime.ParseExact(“20100428165421”, "yyyyMMddHHmmss", new System.Globalization.CultureInfo("zh-CN", true))

 

字符串转换为字节数组

byte[] sarr = System.Text.Encoding.GetEncoding("gb2312").GetBytes(你的字符串)

 

字节数组转换为字符串

string text = System.Text.Encoding.GetEncoding("gb2312").GetString(你的字节数组)

 

返转字符为 output produces code This
string w = "This code produces output";
string r = String.Concat(Regex.Matches(w, @"\w+|\W+").Cast<Match>().Reverse().Select(o => o.Value).ToArray());