.NET 4.0 中的重大变化

编程入门 行业动态 更新时间:2024-10-26 00:31:31
本文介绍了.NET 4.0 中的重大变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有很多关于新 4.0 中的新功能和类的信息,但也有可能影响现有应用程序的更改,例如

There is a lot of information about new features and classes in new 4.0 however there are also changes that may affect existing applications, for example

  • Timespan 现在实现 IFormattable 和旧的 string.Format() 带有无效选项将抛出异常而不是调用简单的 ToString().但是,CLR 团队提供了一个很好的功能,可以通过配置设置启用先前版本的行为 - TimeSpan_LegacyFormatMode .

  • Timespan now implements IFormattable and old string.Format() with invalid options will throw exception instead of calling simple ToString(). However, CLR team provides a nice feature to enable behaviour from previous version with configuration setting - TimeSpan_LegacyFormatMode .

    CLR 由内而外

    访问使用 += 或 -= 声明事件的类内的事件将导致调用返回 void 的添加/删除生成的访问器.有些代码甚至无法在 4.0 中编译.

    Access to events inside the class where they are declared using += or -= will lead to call add/remove generated accessors that return void. Some code won't even compile in 4.0.

    Chris Burrows 博客

    CAS 已弃用,要启用它仍需要在配置中使用特殊设置 - NetFx40_LegacySecurityPolicy

    CAS is deprecated and to enable it one still need to use special setting in configuration - NetFx40_LegacySecurityPolicy

    所以我想知道还有哪些其他更改,是否可以找到至少会或可能会破坏 .NET 4.0 发布的现有功能的更改的初步列表?

    So I wonder what are other changes and is it possible to find at least preliminary list of changes that will or may break existing functionality with release of .NET 4.0 ?

    推荐答案

    语言文档团队针对 C# 和 VB 的重大更改发布单独的文档:

    The languages documentation team publishes separate documents for C# and VB breaking changes:

    VB:msdn.microsoft/en-us/library/cc714070%28VS.100%29.aspx

    C#:msdn.microsoft/en-us/library/ee855831%28VS.100%29.aspx

    我编写了 C#,其中包括 Eric Lippert 提到的协变和逆变破坏性更改,以及 Chris Burrows 讨论的事件更改.还有一些围绕可选参数、嵌入式互操作类型和方法组类型推断的重大更改.

    I wrote the C# one and included covariance and contravariance breaking changes mentioned by Eric Lippert, and events changes discussed by Chris Burrows. There are also some breaking changes around optional parameters, embedded interop types, and method group type inference.

    更新:

    另一个有用的文档(来自 .NET 文档团队):msdn.microsoft/en-us/library/ee941656%28VS.100%29.aspx

    One more useful document (from .NET documentation team): msdn.microsoft/en-us/library/ee941656%28VS.100%29.aspx

  • 更多推荐

    .NET 4.0 中的重大变化

    本文发布于:2023-11-09 05:24:53,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1571499.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:重大变化   NET

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!