版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、.NET框架2.0新特性综述卢斌Software Development EngineerMicrosoft CorporationBCL 新功能Serial portCompressionStrongly typed resourcesConsole supportThreadingDiagnosticsNetworking。Strongly Typed Resources 演 示public class List private object elements; private int count; public void Add(object element) if (count = e
2、lements.Length) Resize(count * 2); elementscount+ = element; public object thisint index get return elementsindex; set elementsindex = value; public int Count get return count; Generics “泛型” public class List private T elements; private int count; public void Add(T element) if (count = elements.Leng
3、th) Resize(count * 2); elementscount+ = element; public T thisint index get return elementsindex; set elementsindex = value; public int Count get return count; List intList = new List();intList.Add(1);intList.Add(2);intList.Add(“3);int i = (int)intList0;List intList = new List();intList.Add(1); / Ar
4、gument is boxedintList.Add(2); / Argument is boxedintList.Add(“3); / Should be an errorint i = (int)intList0; / Cast requiredList intList = new List();intList.Add(1); / No boxingintList.Add(2); / No boxingintList.Add(“3); / Compile-time errorint i = intList0; / No cast requiredC#Generics “泛型” 为什么要Ge
5、nerics?编译时类型验证高性能 (不用装箱box, 不用转换downcasts)减少代码累赘 (typed collections)VB, C#, MC+ 编写和运用 genericsGenerics国际标准化Generics in VBPublic Class List(Of ItemType) Private elements() As ItemType Private elementcount As Integer Public Sub Add(ByVal element As ItemType) If elementcount = elements.Length ThenResiz
6、e(elementcount * 2) elements(elementcount) = element count += 1 End Sub Public Default Property Item(ByVal index As Integer) As ItemType Get Return elements(index) End Get Set (ByVal Value As ItemType) elements(index) = Value End Set End Property Public ReadOnly Property Count As Integer Get Return
7、elementcount End Get End PropertyEnd ClassDim intList As New List(Of Integer) intList.Add(1) No boxing intList.Add(2) No boxing intList.Add(“3) Compile-time error Dim i As Integer = intList(0) No cast requiredVBGenerics in C+genericpublic ref class List array elements; int count;public: void Add(T e
8、lement) if (count = elements-Length) Resize(count * 2); elementscount+ = element; property T default int index T get() return elementsindex; void set(T value) elementsindex = value; property int Count int get() return count; ;List intList = gcnew List();intList-Add(1); / No boxingintList-Add(2); / N
9、o boxingintList-Add(“3); / Compile-time errorint i = intList0; / No cast requiredC+基础类库泛类 (Generics in BCL)System.Collections.Generic classesListDictionaryStackQueueSystem.Collections.Generic interfacesIListIDictionaryIDictionaryICollectionIEnumerableIEnumeratorIComparableIComparerNullable(Of T)Even
10、tHandlerDim intVal as Nullable(Of Integer) = 5If intVal.HasValue Then checks for a valuedelegate void EventHandler(Object sender, T e) where T : EventArgs;提高 CLR 性能长远目标: CLR性能指标与非托管本机代码一致减少多个托管进程的marginal cost减少托管应用程序起动时间和工作集NGEN将 IL 编译成本机代码, 然后存盘好处: 无需反复将 IL 编译成本机代码, 类的布局也已定型, 起动时间更短 CLR 2.0:显著地减少了
11、private, non-shareable工作集ngen install, ngen update, ngen /queue使.NET框架成为更快的编程平台提高现有API的性能降低应用程序域(AppDomain)开销,应用程序域之间的方法调用 (加快 1.1倍-50倍)委托(delegate)创建 (10倍) 和调用 (2倍)UTF8Encoding: translation (2.5倍)新的高性能 API更快的资源查找APILightweight CodeGen: 只生成关键代码 (与 Reflect Emit 对比)TryParse 演 示走向 64 位64 位 Windows 服务器和
12、工作站支持 IA64 和 X64 (AMD64)Windows Server 2003 SP1和未来的64 位 Windows Client支持 WoW6432位应用程序可在 64位机上运行CLR1.0 和1.1应用程序在 WoW64上运行VS: 作为32位应用程序运行可以开发, 调试和部署32位和64位应用程序新的CLR 64位实时编译, 垃圾回收和程序调试服务64bitNONOWOW64YESPE32+ILONLY32BITREQUIREDYESNOYESC# Compiler /platform: : ILONLY, NOT 32BITREQUIRED : 32BITREQUIRED o
13、r : PE32+Space Invaders 演 示CLR安全功能支持新的加密服务(cryptography)支持 PKI and PKCS7支持 XML 加密更好地支持 X509 certificatesDPAPI (Data Protection API)支持托管ACL提高应用程序安全Permission 计算器 (PermCalc)Debug-In-ZoneSecureString 演 示RAD程序调试编辑继续能力 (Edit and Continue)允许的编辑: (例子)给类加新的private字段给类加新的private非虚拟方法改写方法内的代码不允许的编辑: (例子)除去字段或
14、方法编辑泛类 (generics)序列化(Serialization)不认知新的字段Display Attributes 控制调试器显示SQL Server 集成将开发工具 Visual Studio 与数据管理平台 SQL Server 集成在一起将中间层的.NET框架编程模式和开发技能应用到数据层用托管代码写 Stored Procedures, Triggers, data types CLR安全系统(类型安全和代码访问安全)VS .NET 项目文件集: geo.dllVB, C#, BuildSQL ServerSQL 数据: create assembly create functi
15、on create procedure create trigger create type SQL Queries: SELECT name FROM Supplier WHERE Location:Distance ( point ) 3SQL Server承载 CLRSQL CLR 功能 定义 Location.Distance()Sql 编程模式 分割字符串 (Splitting a string)老方法 (T-SQL). declare str varchar(200)select Str = Microsoft Corporation|SQL Server|2003|SQL-CLR
16、|2002-08-20|11:32:00|Document|3.b.3SELECTsubstring(Str + |, 0 + 1, charindex(|, Str + |, 0 + 1) - 0 - 1 ),substring(Str + |, charindex(|, Str + |) + 1, charindex(|, Str + |, charindex(|, Str + |) + 1) - charindex(|, Str + |) - 1 ),substring(Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) +
17、 1, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) - charindex(|, Str + |, charindex(|, Str + |) + 1) - 1 ),substring(Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str +
18、|, charindex(|, Str + |) + 1) + 1) + 1) - charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) - 1 ),substring(Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1, charindex(|, Str + |, charindex(|, Str + |, chari
19、ndex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) - charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) - 1 ),substring(Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, c
20、harindex(|, Str + |) + 1) + 1) + 1) + 1) + 1, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) - charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charind
21、ex(|, Str + |) + 1) + 1) + 1) + 1) - 1 ),substring(Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) + 1, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|,
22、 Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) + 1) - charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) - 1 ),substring(Str + |, charindex(
23、|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) + 1) + 1, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|
24、, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) + 1) + 1) - charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) + 1) - 1 ) T-SQLdeclare str v
25、archar(200)select Str = Microsoft Corporation|SQL Server|2003|SQL-CLR|2002-08-20|11:32:00|Document|3.b.3SELECTsubstring(Str + |, 0 + 1, charindex(|, Str + |, 0 + 1) - 0 - 1 ),substring(Str + |, charindex(|, Str + |) + 1, charindex(|, Str + |, charindex(|, Str + |) + 1) - charindex(|, Str + |) - 1 ),
26、substring(Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) - charindex(|, Str + |, charindex(|, Str + |) + 1) - 1 ),substring(Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1)
27、 + 1, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) - charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) - 1 ),substring(Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |)
28、+ 1) + 1) + 1) + 1, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) - charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) - 1 ),substring(Str + |, charindex(|, Str + |
29、, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) - charindex(|, Str + |, char
30、index(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) - 1 ),substring(Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) + 1, charindex
31、(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) + 1) - charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) -
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年团委下半年活动计划
- 基于RBRVS的科室成本分摊方法应用
- 2026年春节期间施工计划
- 基于DRG的应急医疗成本分摊模型
- 固定资产全流程成本管控:从采购到报废
- 儿科护理中的患者隐私保护
- 合并睡眠呼吸暂停的慢性稳定性心绞痛呼吸支持与药物优化方案
- 可持续化成本管控模式
- 单病种成本核算的准确性控制
- 医院运营成本降本增效的实践路径
- (五调)武汉市2026届高三年级五月调研考试物理试卷(含答案)
- 消防系统维修保养及消防改造施工方案
- 2025年中国邮政集团有限公司云南省分公司第一期见习人员477人笔试历年参考题库附带答案详解
- GJB1406A-2021产品质量保证大纲要求
- 《危险化学品目录》(2026版)
- 内分泌科慢性肾上腺皮质功能减退症诊疗规范2023版
- 《世界名画蒙娜丽莎》课件
- 春小麦田间管理子肥水控制(春小麦栽培课件)
- 收割小麦协议书
- 硒与人类健康-课件
- (完整版)供货计划
评论
0/150
提交评论