随笔分类 -  C#

摘要:写入: StreamWriter s = new StreamWriter(address + "\\Menu.ini", true); s.WriteLine("这里是具体的内容");//写入INI文件 s.Flush(); s.Close();读取: StreamReader sr = new StreamReader(address + "\\Menu.ini"); string[] arrstr = sr.ReadToEnd().Split(new string[] { "\r\n" }, St... 阅读全文
posted @ 2013-12-19 11:14 JasonGu0 阅读(705) 评论(0) 推荐(0)
摘要:获取北京时间(方法有很多,这里只讲其中之一)代码如下: #region GetBeijingTime /// /// 获取标准北京时间2 /// /// public static DateTime GetBeijingT... 阅读全文
posted @ 2013-12-06 14:06 JasonGu0 阅读(2612) 评论(0) 推荐(1)
摘要:首先定义一个接口类:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace MY_Factory{ /// /// interface 是接口,实现接口 /// public interface ICoat { /// /// 方法1 /// void GetYourCoat(); /// /// 方法2 /// v... 阅读全文
posted @ 2013-11-26 14:14 JasonGu0 阅读(513) 评论(0) 推荐(0)
摘要:先定义一个具有返回值(List)的方法 List fun(ref List intcount, int a) { if (1 == a) return intcount; else { List ii = new List(); ii.Add(a - 1); intcount.AddRange(ii); return fun(ref intcount, a - 1); } ... 阅读全文
posted @ 2013-11-12 09:42 JasonGu0 阅读(1162) 评论(0) 推荐(0)
摘要:public static void CreateXml(string path) { XmlDocument xmldoc = new XmlDocument(); XmlTextWriter writer = new XmlTextWriter(path, Encoding.UTF8); writer.WriteStartDocument(); /*根节点*/ writer.WriteStartElement("User");//根节点 /*n... 阅读全文
posted @ 2013-11-06 09:11 JasonGu0 阅读(390) 评论(0) 推荐(0)
摘要:自定义一个生成日志文件的类using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.IO;using PrintDatas;using System.Windows.Forms;namespace PrintDatas.Functionlayer{ public class Log { /// /// 日志系统文件(下载) /// /// 处于什么位置 /// 店铺名称 ... 阅读全文
posted @ 2013-11-01 10:54 JasonGu0 阅读(1844) 评论(0) 推荐(1)
摘要:自定义一个序列化类using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.IO;using System.Runtime.Serialization.Formatters.Binary;using System.Windows.Forms;namespace PrintDatas.Functionlayer{ class SerializableOperate { /// /// 序列化Font /// ... 阅读全文
posted @ 2013-11-01 10:38 JasonGu0 阅读(171) 评论(0) 推荐(0)
摘要:public string GetPYString(string str) { string tempStr = ""; foreach (char c in str) { if ((int)c >= 33 && (int)c /// 取单个字符的拼音声母 /// /// 要转换的单个汉字 /// 拼音声母 string GetPYChar(string c) { byte... 阅读全文
posted @ 2013-10-29 17:02 JasonGu0 阅读(446) 评论(0) 推荐(0)
摘要:private static void DataTableToSQLServer(DataTable dt) { string connectionString = "";//GetConnectionString(); using (SqlConnection destinationConnection = new SqlConnection(connectionString)) { destinationConnection.Open(); us... 阅读全文
posted @ 2013-10-28 14:26 JasonGu0 阅读(683) 评论(0) 推荐(0)
摘要:static void Main(string[] args) {//442048086191605,140454 aa("442048086191605'--", ""); } static void aa(string username, string pwd) { string sql = @"select * from boby_info where tid=@use and intBobyInfoID=@pwd"; SqlConnection conn = ne... 阅读全文
posted @ 2013-10-26 10:46 JasonGu0 阅读(189) 评论(0) 推荐(0)
摘要:在Program里写入代码: static class Program { /// /// 应用程序的主入口点。 /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Application.Run(new FnFather()); ... 阅读全文
posted @ 2013-10-23 09:37 JasonGu0 阅读(191) 评论(0) 推荐(0)
摘要:首先,定义一个带object参数的方法,代码如下: public void ThreadMethod(object ParObject) { List stid = null; SqlConnection con = null; SqlCommand cmd = null; toExport_Mutex.whatOperation optin = new toExport_Mutex.whatOperation(); try { ... 阅读全文
posted @ 2013-10-22 13:33 JasonGu0 阅读(743) 评论(0) 推荐(0)
摘要:使用csc命令将.cs文件编译成.dll的过程很多时候,我们需要将.cs文件单独编译成.dll文件,操作如下:打开命令窗口->输入cmd到控制台->cdC:\WINDOWS\Microsoft.NET\Framework\v1.1.4322转到vs.net安装的该目录下->执行csc命令csc/target:libraryFile.cs->在该目录下产生一个对应名字的.dll文件(前提:把.cs文件放到C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322目录下)csc命令的方式很多,请参考以下译File.cs以产生File.execs 阅读全文
posted @ 2013-10-11 14:51 JasonGu0 阅读(577) 评论(0) 推荐(0)
摘要:先申明一个枚举: public enum Test_Enum { one = 1001, two = 1002, three = 1003, four = 1004, five = 1005, six = 1006, seven = 1007, eight = 1008, nine = 1009, zero = 1000 }获取值: object ojb = Enum.GetName(typeof(Test_Enum),Test_Enum.eight); int i = (int)Test_Enum.eight; 阅读全文
posted @ 2013-09-30 14:17 JasonGu0 阅读(2260) 评论(0) 推荐(0)
摘要:[AttributeUsage(AttributeTargets.Field)] public class EnumExtension : Attribute { private string title; public EnumExtension(string title) { this.title = title; } public static string Get(Type tp, string name) { MemberInfo[] m... 阅读全文
posted @ 2013-09-30 13:54 JasonGu0 阅读(1813) 评论(0) 推荐(0)
摘要:Clipboard.SetDataObject();(附注:有很多重载方法 针对不同的需要 选择不同的方法) 阅读全文
posted @ 2013-09-22 16:10 JasonGu0 阅读(424) 评论(0) 推荐(1)
摘要:private void button1_Click(object sender, EventArgs e) { System.Threading.Thread TestThread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Test)); object test="asdfasdf"; TestThread.Start(test); } private void Test(ob... 阅读全文
posted @ 2013-09-12 10:45 JasonGu0 阅读(240) 评论(0) 推荐(0)
摘要:var result=new DataTable().DefaultView.ToTable(false, "col1", "col2");将DataRow[] 转换成dt类型,并指定dt的列 复制给dt2;DataTable dt2= DataRow[].CopyToDataTable().DefaultView.ToTable(false, "col1", "col2"); 阅读全文
posted @ 2013-09-07 09:59 JasonGu0 阅读(518) 评论(0) 推荐(0)
摘要:一 C# 键值对类有以下类:① IDictionary idc = new Dictionary();② KeyValuePair par = (KeyValuePair)shoplistcomboBox.SelectedItem;③Hashtable ht=new Hashtable(); file创建一个Hashtable实例 ht.Add(E,e);添加keyvalue键值对Hashtable 内的每一组对象就是一个DictionaryEntry 例如我们要循环hashtable foreach (DictionaryEntry de in myHashtable) {...} Has. 阅读全文
posted @ 2013-08-29 09:22 JasonGu0 阅读(1545) 评论(0) 推荐(0)
摘要:第一步:先把string[] 转换成 ArrayList 第二步:移除指定元素第三步:在转换回string[]using System;using System.Collections;class Test{ static void Main() { string [] arr = { "abc1 ", "abc2 ", "abc3 ", }; ArrayList al = new ArrayList(arr); al.RemoveAt(1); arr ... 阅读全文
posted @ 2013-08-24 17:12 JasonGu0 阅读(16638) 评论(0) 推荐(3)