随笔分类 -  C#

摘要:最近被多线程问题(multi-thread issue)弄昏了头。以前虽然也知道系统里要考虑多线程问题,也无数次见到double-check的代码,但是由于自己碰到这方面的问题基本上就是从其他地方拷贝一份现成的代码,改吧改吧,也一直没有遇到多线程带来的bug,所以就没有留心。知道年前,一份两三个月前 阅读全文
posted @ 2017-03-27 10:29 甜菜波波 阅读(2495) 评论(0) 推荐(0) 编辑
摘要:在Net中,由GC垃圾回收线程掌握对象资源的释放,程序员无法掌控析构函数的调用时机。对于一些非托管资源,比如数据库链接对象等,需要实现IDisposable接口进行手动的垃圾回收。那么什么时候使用Idisposable接口,以及如何使用呢? 一、IDisposable的接口定义如下 public i 阅读全文
posted @ 2017-03-24 17:08 甜菜波波 阅读(28399) 评论(0) 推荐(9) 编辑
摘要:using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace 不装箱调用显示实现接口 { class Program { static void Main(string[] args) { /... 阅读全文
posted @ 2017-03-24 16:18 甜菜波波 阅读(157) 评论(0) 推荐(0) 编辑
摘要:当结构类型的值被转换为object 类型或由该结构实现的接口类型时,就会执行一次装箱操作。 阅读全文
posted @ 2017-03-24 15:18 甜菜波波 阅读(140) 评论(0) 推荐(0) 编辑
摘要:一个类只能有一个静态构造函数,该构造函数不能有访问修饰符,不能带任何参数,不能直接调用,只能在: 1 创建类实例时 2 访问包含静态构造函数的静态成员时 会先调用静态构造函数,无论创建了多少个类实例,其静态构造函数都只调用了一次。 阅读全文
posted @ 2017-03-24 11:40 甜菜波波 阅读(162) 评论(0) 推荐(0) 编辑
摘要:using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Reflection; using System.Collections.ObjectModel; namespace 泛基 { class... 阅读全文
posted @ 2017-03-24 10:37 甜菜波波 阅读(260) 评论(0) 推荐(0) 编辑
摘要:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Test { class Program { static void Main(string[] args) ... 阅读全文
posted @ 2017-03-23 15:05 甜菜波波 阅读(3296) 评论(1) 推荐(0) 编辑
摘要:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; using System.Runtime.Remoting.Proxies; using System.Runtime.Remoting.Messaging; using System.Ru... 阅读全文
posted @ 2017-03-17 11:16 甜菜波波 阅读(529) 评论(0) 推荐(0) 编辑
摘要:特别注意 sqlbulkcopy.ColumnMappings.Add(dt.Columns[i].ColumnName, dt.Columns[i].ColumnName); 插入的时候列的顺序可以不一致,但名称和数据类型最好要保存一致。不一致时候,也能进行正确的转换,除了比如DataTime数据 阅读全文
posted @ 2017-03-02 11:27 甜菜波波 阅读(406) 评论(0) 推荐(0) 编辑
摘要:1.所用类库有 Microsoft.Web.Infrastructure.dll 和WebActivator.dll 2.类代码如下 using System; using System.Collections.Generic; using System.Linq; using System.Tex 阅读全文
posted @ 2017-03-02 11:14 甜菜波波 阅读(324) 评论(0) 推荐(0) 编辑
摘要:Yield Return 和 Yield Break 的出现是为了简化迭代器。 类如果能被遍历则必须有IEnumerator<string> GetEnumerator() 方法, 并有用Yield Return 方法如果能被遍历则返回类型为 IEnumerable<string>,并有用Yield 阅读全文
posted @ 2017-03-01 10:10 甜菜波波 阅读(435) 评论(0) 推荐(0) 编辑
摘要:using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace demo12 { class Program { static void Main(string[] args) { Animal ... 阅读全文
posted @ 2017-02-20 11:04 甜菜波波 阅读(212) 评论(0) 推荐(0) 编辑
摘要:explicit 和 implicit 属于转换运算符,如用这两者可以让我们自定义的类型支持相互交换explicti 表示显式转换,如从 A -> B 必须进行强制类型转换(B = (B)A)implicit 表示隐式转换,如从 B -> A 只需直接赋值(A = B)隐式转换可以让我们的代码看上去 阅读全文
posted @ 2017-02-20 10:09 甜菜波波 阅读(987) 评论(0) 推荐(0) 编辑
摘要:using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace demo9 { class Program { static void Main(string[] args 阅读全文
posted @ 2017-02-16 17:42 甜菜波波 阅读(155) 评论(0) 推荐(0) 编辑
摘要:using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace demo5 { class Program { public delegate T del(T t); public static string say(s... 阅读全文
posted @ 2017-02-15 15:06 甜菜波波 阅读(126) 评论(0) 推荐(0) 编辑
摘要:using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace demo3 { class Program { static void Main(string[] args) { ... 阅读全文
posted @ 2017-02-14 11:48 甜菜波波 阅读(259) 评论(0) 推荐(0) 编辑
摘要:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace TestEvent { class MyClass { public delegate void Complet... 阅读全文
posted @ 2016-12-19 15:58 甜菜波波 阅读(134) 评论(0) 推荐(0) 编辑
摘要:利用 Json方法返回 数据时,如果有时间格式,会变成 "\/Date(1369419656217)\/" 这个样子,问了同事找到个解决方法 我们把这个方法封装一下,写到Controller的基类里,创建一个 BaseController 的基类 保证我们每一个Controller去继承这个类 va 阅读全文
posted @ 2016-11-16 17:14 甜菜波波 阅读(212) 评论(0) 推荐(0) 编辑
摘要:DataTable.Select()方法使用和 SQL 相似的过滤语法从 DataTable 中提取你关心的记录,虽然 Select()可以很好的工作,但它还是有一些明显的限制。首先,它是基于字符串的,也就是说可能的错误不能在编译的时候发现。其次,它的过滤功能也很有限,它没有提供 LINQ 操作符能 阅读全文
posted @ 2016-11-16 14:34 甜菜波波 阅读(334) 评论(0) 推荐(0) 编辑
摘要:Aspose.Cells组件可以不依赖excel来导入导出excel文件: 导入: [csharp] view plain copy print? public static System.Data.DataTable ReadExcel(String strFileName) { Workbook 阅读全文
posted @ 2016-11-15 17:39 甜菜波波 阅读(3026) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示