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

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());

原文地址:https://www.cnblogs.com/lilin/p/1726225.html