A lot of the hype around .Net 4.0 is surrounding new features such as the Dynamic Language Runtime (DLR), and C# 4.0 features such as the dynamic type and co/contra-variance. Something not getting as much press, but in many ways more helpful is the inclusion of many new, useful types included in 4.0. The BCL team has a blog article about many of these types. Here are a couple of my favorites:
- Enum.HasFlag(Enum enum)
I have written this code a couple of times before. It detects whether a bit is set in an enum Flag value. - Enum.TryParse<EnumType>(string value, out EnumType result)
I have also had to write this. I think every core value-type should have a TryParse, which leads to: - Guid.TryParse(string value, out Guid result)
- String.Join and String.Concat now take IEnumerable<T>! I have written string.Join(“,”, values.Select(v=>v.ToString()).ToArray()) more that a few times.
I am really looking forward to .Net 4.0. If you want to get your hands on it now .Net 4.0 and Visual Studio 2010 are available for download here.
