菜单
  
    Overview of Features Added in C# 2.0 and C# 3.0 Since its initial release in late 2000, the C# language has evolved considerably. This evolution has likely been accelerated thanks to the wide adoption of C#. With the release of Visual Studio 2005 and the .NET Framework 2.0, the C# compiler supported the C# 2.0 enhancements to the language. This was great news, since C# 2.0 included some handy features that provided a more natural programming experience as well as greater efficiency. 39925
    Arguably, the meatiest addition to C# 2.0 was support for generics. The syntax is similar to C++ templates, but the main difference is that constructed types created from .NET generics are dynamic in nature—that is, they are bound and constructed at run time. This differs from C++ concrete types created from templates, which are static in the sense that they are bound and created at compile time.
    Generics are most useful when used with container types such as vectors, lists, and hash tables, where they provide the greatest efficiency gains. Generics can treat the types that they contain specifically by their type, rather than by using the base type of all objects, System.Object.
    C# anonymous methods are extremely useful with delegates and events. Delegates and events are constructs used to register callback methods that are called when triggered. Normally, you wire them up to a defined method somewhere. But with anonymous methods, you can define the delegate’s or event’s code inline, at the point where the delegate or event is set up. This is handy if your delegate merely needs to perform some small amount of work for which an entire method definition would be overkill. What’s even better is that the anonymous method body has access to all variables that are in scope at the point it is defined.Lambda expressions, which are new to C# 3.0, supersede anonymous methods and make for more readable code.
    C# 2.0 added support for iterators. Anyone familiar with the C++ Standard Template Library (STL) knows about iterators and their usefulness. In C#, you typically use the foreachstatement to iterate over an object that behaves as a collection. 
    Finally, C# 2.0 added support for partial types. Prior to C# 2.0, you had to define each C# classentirely in one file (also called a compilation unit). This requirement was relaxed with the support for partial types. This was great news for those who rely upon code generators to provide skeleton code. For example, you can use the Visual Studio wizards to generate such useful things as System.Data.DataSetderived types for accessing data in a database. Prior to C# 2.0, it was problematic if you needed to make modifications to the generated code. You either had to derive from or contain the generated type in a new type while specializing its implementation, or you had to edit the generated code. Editing the generated code was risky because you normally lost those changes when the wizard was forced to regenerate the type for some reason. Partial types solve this problem, because now you can augment the generated code in a separate file so that your changes aren’t lost when the wizard regenerates the code. For a great example of how partial types are used, look at the code automatically generated when you create a Windows Forms application using Visual Studio.
    C# 3.0 includes some great new features. Most of the new features are stepping stones designed to support Language Integrated Query (LINQ). Nevertheless, all of them are extremely useful when used inpidually outside of the context of LINQ. Many of them allow programmers to employ functional programming techniques more easily.
    C# now supports implicitly typed local variables by making use of a new keyword var. It’s important to note that these variables are not typeless; rather, their type is inferred at compile time.
    Auto-implemented properties are another helpful new feature to save us some typing and reduce the potential to introduce bugs. How many times have you simply declared a class to hold a few pieces of data and been annoyed with the amount of typing required to create property accessors for that data? After all, doing so follows good encapsulation practices.
  1. 上一篇:JSP技术的发展历程英文文献和中文翻译
  2. 下一篇:探索Activity的生命周期英文文献和中文翻译
  1. 汽车内燃机连杆载荷和应...

  2. 机械手系统英文文献和中文翻译

  3. 固体氧化物燃料电池英文文献和中文翻译

  4. 船舶运动仿真系统英文文献和中文翻译

  5. 新能源空调系统设计英文文献和中文翻译

  6. 正交试验回归法和响应曲...

  7. 机械设计制造及其自动化英文文献和中文翻译

  8. 现代简约美式风格在室内家装中的运用

  9. 中国传统元素在游戏角色...

  10. g-C3N4光催化剂的制备和光催化性能研究

  11. 江苏省某高中学生体质现状的调查研究

  12. C++最短路径算法研究和程序设计

  13. NFC协议物理层的软件实现+文献综述

  14. 巴金《激流三部曲》高觉新的悲剧命运

  15. 上市公司股权结构对经营绩效的影响研究

  16. 高警觉工作人群的元情绪...

  17. 浅析中国古代宗法制度

  

About

优尔论文网手机版...

主页:http://www.youerw.com

关闭返回