博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C#二进制与字符串之间的相互转换
阅读量:1523 次
发布时间:2019-04-21

本文共 1357 字,大约阅读时间需要 4 分钟。

1     ///  2     /// 将字符串转成二进制 3     ///  4     ///  5     /// 
6 public static string bianma(string s) 7 { 8 byte[] data = Encoding.Unicode.GetBytes(s); 9 StringBuilder result = new StringBuilder(data.Length * 8);10 11 foreach (byte b in data)12 {13 result.Append(Convert.ToString(b, 2).PadLeft(8, '0'));14 }15 return result.ToString();16 }

将二进制转成 字符串

1     ///  2     /// 将二进制转成字符串 3     ///  4     ///  5     /// 
6 public static string jiema(string s) 7 { 8 System.Text.RegularExpressions.CaptureCollection cs = 9 System.Text.RegularExpressions.Regex.Match(s, @"([01]{8})+").Groups[1].Captures;10 byte[] data = new byte[cs.Count];11 for (int i = 0; i < cs.Count; i++)12 {13 data[i] = Convert.ToByte(cs[i].Value, 2);14 }15 return Encoding.Unicode.GetString(data, 0, data.Length);

//JS 进行计算自然年月季度周天数

  
var now = new Date();
//加五天.
var newDate = DateAdd("d ", 5, now);
alert(newDate.toLocaleDateString())
//加两个月.
newDate = DateAdd("m ", 2, now);
alert(newDate.toLocaleDateString())
//加一年
newDate = DateAdd("y ", 1, now);
alert(newDate.toLocaleDateString())

 

}
}

转载于:   https://www.cnblogs.com/weihengblogs/archive/2013/12/23/3487257.html

转载于:https://www.cnblogs.com/LowKeyCXY/p/8549903.html

你可能感兴趣的文章