随笔分类 -  C#

摘要:View Code 1 using System; 2 using System.IO; 3 using System.Net; 4 using System.Text; 5 using System.Security; 6 using System.Threading; 7 using System.Collections.Specialized; 8 using Sort; 9 10 namespace Sort 11 { 12 // <summary> 13 /// 记录下载的字节位置 14 /// </summary> 15 pub... 阅读全文
posted @ 2012-12-27 18:04 宁静.致远 阅读(342) 评论(0) 推荐(0)
摘要:父对象页Cell cell = new Cell();//居中显示cell.WindowStartupLocation = WindowStartupLocation.CenterScreen;//绑定事件cell.pevent += new Cell.PassResultHandler(RefreshData);事件触发后调用RefreshData() 方法-------------------------子对象页面//申明委托 public delegate void PassResultHandler(List<ArchivesEntity.FileBox> boxlist) 阅读全文
posted @ 2012-12-26 16:10 宁静.致远 阅读(199) 评论(0) 推荐(0)
摘要:public void WriteMessage(string filename, string message, string method) { string path = GetAssemblyPath() + @"\errorlog.txt"; FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite); using (StreamWriter sw = new StreamWriter(fs)) { sw.BaseStream.Seek(0, SeekOrigi 阅读全文
posted @ 2012-12-14 13:50 宁静.致远 阅读(153) 评论(0) 推荐(0)
摘要:int aa = 111;string aastr = aa.ToString("0000000");//或string aastr = aa.ToString().PadLeft(7,'0');string.Format(" {0:d7}", i);123.ToString("d7"); 阅读全文
posted @ 2012-12-14 13:36 宁静.致远 阅读(339) 评论(0) 推荐(0)
摘要://获取包含清单的已加载文件的路径或 UNC 位置。 public static string sApplicationPath = Assembly.GetExecutingAssembly ( ).Location; //result: X:\xxx\xxx\xxx.dll (.dll文件所在的目录+.dll文件名) //获取当前进程的完整路径,包含文件名(进程名)。 string str = this.GetType ( ).Assembly.Location; //result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名) //获取新的 Proc. 阅读全文
posted @ 2012-08-25 12:35 宁静.致远 阅读(376) 评论(0) 推荐(0)
摘要:1.error和exception有什么区别? 2.List, Set, Map是否继承自Collection接口? 3.abstract class和interface有什么区别? 4.abstract的method是否可同时是static,是否可同时是native,是否可同时是synchronized? 5.接口是否可继承接口? 抽象类是否可实现(implements)接口? 抽象类是否可继承实体类(concrete class)? 6.启动一个线程是用run()还是start()? 7. 构造器Constructor是否可被override? 8.是否可以继承String类? 9. 当一 阅读全文
posted @ 2012-05-10 21:19 宁静.致远 阅读(278) 评论(0) 推荐(0)
摘要:泛型:通过参数化类型来实现在同一份代码上操作多种数据类型。利用“参数化类型”将类型抽象化,从而实现灵活复用。例子代码:class Program{ static void Main(string[] args) { int obj = 2; Test test = new Test(obj); Console.Write("int:"+test.obj); string str = "hello world"; Test test = new Test(str); Console.Write("string:"+test.obj); 阅读全文
posted @ 2012-05-10 21:16 宁静.致远 阅读(214) 评论(0) 推荐(0)
摘要:最近在用C#的DropDwonList做数据绑定的时候遇到一个小Bug,发现每次不管选择下拉框中的哪一项,刷新页面后总后总是回到第一项,开始还以为是没有用IsPostBack,后来发现不是。百思不得其解,最后在网上查了一下,原来是我绑定的Value值相同导致的,C#判断选项的时候会根据Value来判断,但是如果出现重复项,就会按原来绑定的顺序排列。去掉Value的绑定项,问题解决。 阅读全文
posted @ 2012-05-10 21:12 宁静.致远 阅读(414) 评论(0) 推荐(0)