随笔分类 - c#
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using NPOI.HSSF.UserModel;using NPOI.POIFS.FileSystem;using NPOI.SS.UserModel;using NPOI.SS.Util;using NPOI.HSSF.Util;using NPOI.HSSF.UserModel.Contrib;using System.IO;namespace ConsoleApplication7{ class Class11 ...
阅读全文
摘要:要用到的一些类库如下,它实际是将物理空间转化为一个C#对象,这个对象提供了很多操作的方法.====================================c#里的文件操作fileInfodir的一大堆属性不用说地球人都知道(什么fileName,create()delete()),文件系统的概念很好理解的文件读写也好理解(硬盘到内存然后再到显示器)现在要说的是StreamWriter跟BinaryWriter的区别可以这样理解:streamwriter是用来写文本文件的binary是用来写二进制文件的如果你用一个Binaryreader来读用streamwriter来写一个包含字母a的
阅读全文
摘要:看MSDN时,关键看这句话System.Drawing Namespace命名空间这句话,从这句话开始入手就行了.TheGraphicsclass provides methods for drawing to the display device.Classes such asRectangleandPointencapsulate GDI+ primitives.ThePenclass is used to draw lines and curves, while classes derived from the abstract classBrushare used to fill th
阅读全文
摘要:C#获取Excel各类信息的方法http://hi.baidu.com/it_program/item/66459ae9e7cd08395a7cfb33Cell1Type: System.ObjectThe name of the range in A1-style notation in the language of the application.It can include the range operator (a colon), the intersection operator (a space), or the union operator (a comma).It can a
阅读全文
摘要:对于文件,数据库,网络等非.NET资源,要显式地释放资源,MSDN有个例子using System;using System.ComponentModel;// The following example demonstrates how to create// a resource class that implements the IDisposable interface// and the IDisposable.Dispose method.public class DisposeExample{ // A base class that implements IDisposa...
阅读全文
摘要:通常情况下我们执行数据库操作时都会将SqlConnection实例先打开,用完之后就将它关闭.但万一我忘记关闭了,会造成什么后果.讲后果之前,我们先来说下SqlConnection是怎样和数据库建立连接的,当首次open时,数据库会对发来的连接串进行一系列验证,这个过程会花费比较长的时间,然后为它分配一个连接池,当下次再用这个串时,这连串的验证就可以跳过了,所以耗很短的时间就完成了open.但问题来了,如果再次连接时,它发现这个串对应的连接池没有关闭,则会重新分配一个连接池,当然也会进行那一系列验证,现在还会造成SQL进程不断增加.如下图,所以我们在open完之后一定要记录关闭.
阅读全文
摘要:以下代码可以对比FileStream 和BufferedStream的性能,但一定要注意BufferedStream初始时第二个参数一定要比第一个参数的流的大小要大,不然内存缓存就可能用不上static void Main(string[] args) { Random rd = new Random(); byte[] bb=new byte[1024]; rd.NextBytes(bb); FileStream fs = new FileStream(@"C:\Users\jim\Desk...
阅读全文
摘要:unicode 统一的一种编码,它包括ucs-2,ucs-4ucs 通用字符集ucs-2 两个字节编码,是常见的unicode编码ucs-4 四个字节编码window 文本的unicode是little endian 低位开头对于英文来说,直接用unicode来储存是非常浪费空间和不利于传输,所以就出现了UTF-8,UTF-8是unicode和一种实现方式,只是它的储存方式有所不同,它每个字节都有个头标记,如0XXX XXXX开头就表示一个字节为一个unicode编码,110X XXXX 10XX XXXX两个字节为一个unicode编码,UTF-16多出的部分是ucs-2还是ucs-4??1
阅读全文
浙公网安备 33010602011771号