随笔分类 -  c#

摘要:static bool IsNumeric(string str){ if (str == null || str.Length == 0) return false; foreach (char c in str) { if (!Char.IsNumber(c)) { return false; } } return true; } 阅读全文
posted @ 2012-05-29 20:59 刘振明 阅读(173) 评论(0) 推荐(0)
摘要:/// <summary> /// 将参数扩展为指定长度的字符串,不足位数的在前方加0 /// </summary> /// <param name="origin"></param> /// <param name="length"></param> /// <returns></returns> public static string GetLengthString(string origin, int length) { int l = origin. 阅读全文
posted @ 2012-05-29 20:09 刘振明 阅读(363) 评论(0) 推荐(0)
摘要:class ServerUtils { private static ServerUtils _instance = new ServerUtils(); public static ServerUtils getInstance() { return _instance; } XmlDocument doc = new XmlDocument(); private string serverIp; private string typecode; public string getServerIp() { doc.Load("XMLFile1.xml"); XmlNode 阅读全文
posted @ 2012-05-29 20:07 刘振明 阅读(198) 评论(0) 推荐(0)
摘要:首先将读取的数据库字段用Convert.ToDateTime("字符串"); 转换成DateTime对象,然后用格式化函数对时间进行格式化。如下:DateTime dt=Convert.ToDateTime("str"); 括号中带不带引号我忘了你自己试一下就ok了时间格式化输出:Label1.Text = dt.ToString();//2005-11-5 13:21:25 Label2.Text = dt.ToFileTime().ToString();//127756416859912816 Label3.Text = dt.ToFileTimeU 阅读全文
posted @ 2012-05-29 20:05 刘振明 阅读(261) 评论(0) 推荐(0)
摘要:using System;using System.Text;namespace ConsoleApplication{ class ChineseCode { public static void Main() { //获取GB2312编码页(表) Encoding gb=Encoding.GetEncoding("gb2312"); //调用函数产生4个随机中文汉字编码 object[] bytes=CreateRegionCode(4); //根据汉字编码的字节数组解码出中文汉字 string str1=gb.GetString((byte[])Convert.Cha 阅读全文
posted @ 2012-05-28 22:06 刘振明 阅读(997) 评论(0) 推荐(0)
摘要:http://msdn.microsoft.com/zh-cn/library/ie/w4yc3e8c(v=vs.80) 阅读全文
posted @ 2012-05-08 13:38 刘振明 阅读(266) 评论(0) 推荐(0)
摘要:MySqlConnection conn = new MySqlConnection("User Id=root;PassWord=sa;Host=localhost;Database=mis;");conn.Open();MySqlDataAdapter da = new MySqlDataAdapter("select id, name, age from `mis`.`users` ",conn);DataSet ds = new DataSet();da.Fill(ds,"users"); conn.Close();DataG 阅读全文
posted @ 2012-01-07 22:58 刘振明 阅读(308) 评论(0) 推荐(0)
摘要:string mySqlstring = string.Format("select * from woman where Id='{0}'", woman.Id); MySqlCommand mySqlCommand = new MySqlCommand(mySqlstring, connServer); MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(mySqlCommand); DataSet dataSet ... 阅读全文
posted @ 2012-01-07 22:53 刘振明 阅读(302) 评论(0) 推荐(0)