Things in the .NET Framework 4 Every Programmer Should Know

I recently switched to Visual Studio 2010 and updated my site to work with the .NET Framework 4. (From VS 2008 - Framework 3.5)

What do I need to know to improve site speed, readability, or memory usage?

+71
Apr 22 2018-10-22T00:
source share
16 answers

The rest of Parallel provides some other great things like Parallel.Invoke(...) and Parallel.ForEach(...) .

In addition, if you are doing something with Linq, you can use the ParallelEnumerable.AsParallel () method to convert your Linq queries to work in parallel.

All this is built on a parallel task library , which provides an excellent set of APIs for working with tasks in an abstract way that scales to any resources, your machine does not have to think too much about how many threads you create.

+66
Apr 22 2018-10-22T00:
source share

The DirectoryInfo class in addition to the GetDirectories and GetFiles methods now has its lazy versions of EnumerateDirectories and EnumerateFiles , which allow us to have large arrays for storing all objects at once.

+21
Apr 27 '10 at 20:01
source share

string.Join() now has a signature that accepts IEnumerable<T> instead of just string[] - a small improvement that allows you to .Select() code .Select() and .ToArray() .

+18
Apr 25 '10 at 4:28
source share

The amazing thing is, you can change customer IDs:

http://weblogs.asp.net/scottgu/archive/2010/03/30/cleaner-html-markup-with-asp-net-4-web-forms-client-ids-vs-2010-and-net- 4-0-series.aspx

No more CTL0001 $ _DIV0003_TextBox1001 $ or something else ...

+15
Apr 25 '10 at 5:02
source share

I just like that the web.config file is small and meaningful, not long and full of unknown statements ...

+13
Apr 25 '10 at 4:21
source share

Additional options are one of my favorites. The dynamic type seems promising

+12
Apr 22 2018-10-22T00:
source share

The way C # implements event fields is new. By default, it no longer makes a very bad lock (this) . However, events are still thread safe, because the Interlocked.CompareExchange(...) mechanism is used instead.

This leads to some changes that can be broken in some cases. Additional Information:

+9
Apr 22 2018-10-22T00:
source share
+9
Apr 28 2018-10-22T00:
source share

System.Numerics.BigInteger - An arbitrarily large signed integer.

System.Numerics.Complex - is a complex number.

+5
Jun 06 2018-10-06T00:
source share

Code contracts look very promising both in terms of creating more correct code and in terms of creating more complete documentation. Unfortunately, they are not all present in VS2010 yet - you need to install the add-in, and even then it will not be completed and will not be completed and will not work yet.

+4
Apr 25 '10 at 4:32
source share

You can use memory mapped files (just like Windows native functions, access memory mapped files) to edit very large files and create shared memory for interprocess communication. For a detailed explanation, see: http://msdn.microsoft.com/en-us/library/dd997372.aspx

+4
May 31 '10 at 9:13
source share

For ASP.NET programmers , the ASP.NET 4 and Visual Studio 2010 web development overview provides a comprehensive overview of the new ASP.NET 4. For a series of articles on the most noticeable and interesting changes, I would recommend Scott Gutierie a series of blog posts on VS 2010 and. NET 4 series .

+3
Apr 22 '10 at 19:09
source share

ASP.net cache is now in its own assembly!

System.runtime.caching.dll

which means that you can use it in other applications such as WPF and WinForms, without having to retrieve the entire assembly of system.web

I just want them to increase the CacheItem to include inline information about the cache element, for example, when it was added ... when it expires, etc.

+3
May 21 '10 at 12:32
source share

I would also like to refer to the source documentation (MSDN in this case) for a complete list of improvements and additions:

http://msdn.microsoft.com/en-us/library/ms171868.aspx

From this article, you can easily find something that can improve your existing code base.

+2
Apr 27 '10 at 19:04 on
source share

For readability purposes, I will add my discovery as written in this question.

When using AJAX, you can specify the EnableCdn property of the scriptManager to load values ​​from the CDN (e.g. Microsoft CDN)

+1
Apr 22 '10 at 12:12
source share

I believe there are also WCF improvements that fix previous troubles, such as the inability to configure WebGet / WebInvoke differently for each endpoint in .Net 3.5. I believe it is fully configurable in 4.0.

0
Apr 22 '10 at 18:56
source share



All Articles