Skip to main content

07042010191 Note: This post is part of a series and you can find the rest of the parts in the series index.

There is a bunch of tiny additions in .NET 4 which I have not covered yet, this post provides a quick hit list of some of the new and improved features:

New

  • new StringBuilder.Clear: Quick method to clear a string builder.
  • new StopWatch.Reset: Quick method to reset a stop watch timer.
  • new IntPtr & UIntPtr: Both have had two new methods added, one for addition and one for subtraction.
  • new Thread.Yield: Allows you to yield execution to another thread that is ready to run on the current processor.
  • new System.Guid: Has got two new methods, TryParse and TryParseExact to allow for testing of the parsing.
  • new Microsoft.Win32.RegistryView: This allows you to request 64bit or 32bit views of the registry.
  • new Environment: Now contains two properties to identify 64bit scenarios:
    • Is64BitOperatingSystem: To identify if the OS is 64bit.
    • Is64BitProcess: To identify if the process is 64bit.
  • new System.Net.Mail.SmtpClient: Support for SSL

Improved

  • better Path.Combine: A new method overload to allow you to combine file paths.
  • better Compression.DeflateStream & Compression.GZipSteam: They have been improved so that they so no try to compress already compressed data.
  • better Compression.DeflateStream & Compression.GZipSteam: The 4Gb size limit has been removed.
  • better Monitor.Enter: A new overload has been added which allows you to pass in a reference boolean which returns true of the monitor was successfully entered.
  • better Microsoft.Win32.RegistryOptions: Now includes an option to specify a volatile key which is removed when the system restarts.
  • better Registry keys are no longer limited to 255 characters.
  • better System.Net.Mail.MaiMessage: Support for new headers
    • HeadersEncoding: Sets the type of text encoding used in the mail header.
    • ReplyToList: Sets the list of addresses to use when replying to a mail. This replaces ReplyTo which only supported one email address.
  • better System.Net.NetworkCredential: To improve security passwords can now be stored in a SecureString.
  • better ASP.NET Hashing: The default value has been changed from SHA1 to SHA256.
  • better ASP.NET Output caching: Previously setting the output cache to ServerAndClient also required calling SetOmitVaryStar to ensure it would be cached on the client. From .NET 4, calling of SetOmitVaryStar is no longer needed.
  • better TimeZoneInfo.Local & DateTime.Now: Both of these follow the OS daylight savings settings rather than using the .NET Framework settings.
  • better When running on Windows 7, locale info will be retrieved from the OS rather than being stored in the framework.
  • better Support for all 1400 characters of Unicode 5.1.
  • better ServiceInstaller.DelayedAutoStart: If you on a more modern OS (Vista, Win 7 etc…) then you can services can start as Automatic Delayed. This means they start, but after system boot so that the user gets in quickly. This is now possible for your .NET apps using the DelayedAutoStart property.