文章分类 - c#
摘要:一般情况下,当在.net中使用“稀缺”的资源时,例如数据库连接。窗口或图像对象,最好确保每个资源在使用后立即关闭。尽管.net的设计人员实现了自动的垃圾收集,垃圾最终都是会被回收,但仍需要尽可能早地释放资源,以避免出现资源匮乏的情况。 当编写访问数据库的代码时,这是非常明确的,因为使连接打开的时间略长豫需要的时间,就可能影响其他会话。在极端的情况下,不关闭连接会使其他用户无法进...
阅读全文
摘要:c#可以通过Process启动一个外部程序,同样也可以关闭一个程序,具体代码: 1 System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcesses(); 2 3 foreach (System.Diagnostics.Process myProcess in myPr...
阅读全文
摘要:最近做了一个项目,里面用到的了字符串的拆分,于是偶先把那个东东拿出来分享下。 using System; using System.Collections.Generic; using System.Text; namespace Test_01 { class Program { static void Main(string[] args) {...
阅读全文
摘要:在网上看到这样一个类,觉得挺有收藏意义的,可能以后会用到,就拿出来分享了,呵呵。 1using System; 2using System.Collections.Generic; 3using System.Text; 4 5namespace MyW3C.MyWeather.Core 6{ 7 /**//// 8 /// ...
阅读全文
摘要:1/**//// 2 /// 递归方式删除文件夹及文件夹内的文件 3 /// 4 /// 文件夹名称 5 private void DeleteFolder(string dir) 6 { 7 if (Directory.Exists(dir)) 8 { 9 ...
阅读全文
摘要:今天在csdn的icode中C#专栏中看到这样的代码,自己觉得挺好用,就拿出来分享了。 1using System; 2using System.Collections.Generic; 3using System.ComponentModel; 4using System.Data; 5using System.Drawing; 6using System.Text; 7using Syste...
阅读全文
摘要:利用Application类的StartupPath属性获取启用了应用程序的可执行文件的路径,不包含可执行文件的名称。 1string myInfo = "应用程序的执行文件目录是:\n"+Application.StartupPath;2MessageBox.Show(myInfo);
阅读全文
摘要:方法一:使用vs05中的MasktedTextbox控件,并可以通过属性Mask对其输入规则进行选择,其中包含电话、数字、日期、身份证号等多种验证方式方法二:使用传统的textbox控件1.要增加命名空间 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--...
阅读全文
摘要:新建窗体项目,并添加listview控件listview属性设置 visw Details GirdLine true FullRowSelect t...
阅读全文
浙公网安备 33010602011771号