随笔分类 -  C#

常用的代码
管理程序中的DLL
摘要:1个项目中用到了很多DLL,而NET默认只能把这些DLL全部和EXE程序放在同1个目录下,而我想把所有控件功能的dll放在1个Control的文件夹下面,这样方便管理。 要实现上面的功能很简单,首先为程序加个应用程序配置文件app.config,代码如下:<?xmlversion="1.0"encoding="utf-8"?><configuration><runtime><assemblyBindingxmlns="urn:schemas-microsoft-com:asm.v1">& 阅读全文
posted @ 2013-03-07 11:03 雇佣兵333 阅读(243) 评论(0) 推荐(0)
操作服务
摘要:判断Window服务是否存在View Code public static bool ServiceIsExisted(string serviceName) { ServiceController[] servicesController = ServiceController.GetServices(); foreach (ServiceController each in servicesController) { if (each.ServiceName.ToLower().... 阅读全文
posted @ 2013-01-17 18:17 雇佣兵333 阅读(282) 评论(0) 推荐(0)
操作Excel
摘要:读取Excel中数据到DataSetView Code static public DataSet ExcelToDataSet(string filename, DataSet ds) { //string strConn = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = " + filename + ";Extended Properties=Excel 8.0"; string strConn = " Provider = Microsoft.ACE.OLEDB.12.0... 阅读全文
posted @ 2013-01-17 17:46 雇佣兵333 阅读(283) 评论(0) 推荐(0)
C# 集合与Linq 总结 序列化与反序列化
摘要:将DataTable 转换List <T> 1)要求DataTable中的列名称必须和实体的属性名称相同 public static List<TResult> DataTableToList<TResult>(DataTable dt) where TResult : class,new() { //创建一个属性的列表 List<PropertyInfo> prlist = new List<PropertyInfo>(); //获取TResult的类型实例 反射的入口 ... 阅读全文
posted @ 2013-01-17 13:52 雇佣兵333 阅读(1630) 评论(0) 推荐(0)