Microsoft is consistently improving its .NET framework and providing its developers with enough tools to build sophisticated and large scale enterprise applications easily. Couple of months ago Microsoft released it’s latest version of .NET Framework, version 4.0, with tonnes of new features. Starting from CLR to WPF and Visual Studio 2010, almost all the components .NET eco system are upgraded in the new version.
In this post, I’m going to thro some light on what is new in .NET Framework for developers who write code each and every day. Basically this is for junior developers who are more interested in learning the basics like new types, methods rather than interested in learning parallel programming and dynamic programming concepts.
New Types That Lets You Store Complex Values
This is a new structure introduced to operate on arbitrary large integer values. The existing data types byte, int have definite bounds that are defined by MinValue and MaxValue. But the BigInteger type does not have any bounds, you can store virtually any integer value.
So when to choose a BigInteger over the standard types like byte, int or long? If you are not sure of the size of resulting mathematical value, then use BigInteger. Or if you want to store an integer value like 91389681247993671255432112000000, which is not supported by primitive types.
BigInteger allows us to perform a variety of operations ranging from based additions to binary operations like XOr and OR.
You can read more details about BigInterger at MSDN and well as this blog post.
Do you remember the Complex numbers we use to learn while studying 12th grade maths & physics? Yeah, Complex number are widely used in solving problems in physics, astronomy and geometry.
.NET Framework 4.0 have a new structure called Complex to manipulate Complex numbers. So the developers who are writing complex mathematical and physics app should be happy with the new type. For more information read this MSDN page
Yet another data type for mathematicians. The .NET 4.0 type Tuple provides static methods for creating instances of the tuple types. Here is an example of defining a tuple in .NET 4.0 C# language
var primes = Tuple.Create(2, 3, 5, 7, 11, 13, 17, 19);
For more details on Tuple type in .NET check this MSDN article, if you want to know the basics of Tuples then head towards Wikipedia.
New Methods On Often Use Types/Classes
- The new String.IsNullOrWhiteSpace method indicates whether a string is null, empty, or consists only of white-space characters. Ah! Checking of white space string is very easy now.
- Want to clear a string builder object? Call the new StringBuilder.Clear method. No need to call the Remove method anymore,.
- You can now copy data from one stream to another with the help of method System.IO.Stream.CopyTo
- String.Concat method now lets you concatenate any type of input arrays without converting them to string elements first. Pass integer array to the method, it converts them to string internally and concatenates them. Less code to write.
- Now you can perform TryParse and TryParseExact on System.Guid structure
- The 4 GB limit on System.IO.Compression.DeflateStream and System.IO.Compression.GZipStream are now removed. Compressing big files with .NET is no longer a problem.
- New Path.Combine method overloads enable you to combine file paths
For a complete list of new types and methods introduced in .NET Framework 4.0 check this page: New Types and Members in the .NET Framework 4
For a complete list of new features in .NET Framework 4.0 check the page: What’s New in the .NET Framework 4