Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Things in .NET Framework 4 that every programmer should know [closed]

Tags:

.net-4.0

People also ask

Is .NET framework 4.0 still supported?

Support for . NET Framework 4 on Windows Server 2003 SP2 ended on July 14, 2015, and support on all other operating systems ended on January 12, 2016.

Is .NET Framework end of life?

NET Framework versions 4.5. 2, 4.6, and 4.6. 1 ended on April 26, 2022, so security fixes, updates, and technical support for these versions will no longer be provided.

How long will .NET Framework 4.5 be supported?

NET Framework 4.5. 2, 4.6, and 4.6. 1 will reach end of support* on April 26, 2022. After this date, we will no longer provide updates including security fixes or technical support for these versions.


  • Parallel for loops

    Parallel.For(0,10,(i)=>
    {
        // Do stuff in parallel.
    });
    

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

Also, if you do anything with Linq, you can use the ParallelEnumerable.AsParallel() Method to convert your Linq queries to run in parallel.

It's all built on the Task Parallel Library which provides a great set of API's for working with tasks in an abstracted way that scales for whatever resources your machine has without having to think too much about exactly how many threads you are creating.


The DirectoryInfo class in addition to the GetDirectories and GetFiles methods now has their lazy versions EnumerateDirectories and EnumerateFiles, which avoid us to have large arrays to hold all the objects at once.


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


Awesome thing, Client IDs can be manipulated:

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 whatever...