NET 2.0学习

 

Stopwatch类:

提供一组方法和属性,可用于准确地测量运行时间

 

Stopwatch myWatch = new Stopwatch();

myWatch.Start();

代码段

myWatch.Stop();

Text1Box.Text="运行时间 " +  myWatch.ElapsedMilliseconds.ToString() + " ms";

 

 

读取数据库联接字段

ConnectionStringSettings myConnectionSettings = ConfigurationManager.ConnectionStrings[myconnectionstr];

使用ConfigurationManager时必须将System.configuration库引用而不能只简单的使用using

 

20提供了一个DbProviderFactory的工厂类,使用前需 using System.Data.Common;

 

关键字partial 2.0新提供的。可以将代码拆分到多个文件

 

 

通过工程中的Settings.settings来设置属性值,在代码中通过

Properties.Settings.Default.mysettingstr来读取属性值

Properties.Settings.Default.Save();来保存属性值

这样可以实现代码与设置的分离。数据存储在user.config.xml文件

 

 

 

原文地址:https://www.cnblogs.com/forrestsun/p/347050.html