Tag: .NET

It’s been a while since I’ve done a programming post, but something came up the other day that I thought might be useful. In one of my current projects, I needed to determine the number of words in a string. …

Counting word in a string in C# Read More »

Tagged with: ,

It is very common with threaded applications to need to share data between threads, often in the form of dictionaries, lists, stacks, etc. However, the standard containers (generic or otherwise) in .NET are not thread-safeā€”if you just, say, reference a …

Thread-safe generic collections, containers and dictionaries in .NET Read More »

Tagged with: , , ,

In a previous post, I demonstrated a convenient way to make a wait cursor show up during “reasonably” long operations (up to a few seconds). For anything longer than that, though, a wait cursor won’t cut it — for one …

Handling long operations with cancel and progress in C# with async Read More »

Tagged with: , , , , , , ,

I actually did a post around this topic a while ago on another site that is now defunct, but I figured it is still useful, and I have a few additional details to add. Back in the C++/MFC days, there …

C# Wait Cursor that automatically goes away Read More »

Tagged with: , , ,

With the recent release of C# 6.0, I thought it would be good to provide a brief explanation of the new features of the language. I’ve done them as individual posts: Null-conditional operators Auto-property initializers using static Expression bodies on …

New features of C# 6.0 Read More »

Tagged with: ,

This is one of a series of posts on some of the new features in C# 6.0, which was just released. When Linq was added, a number of cool side-features ended up being added as well–these were things that were …

Index initializers Read More »

Tagged with: ,

This is one of a series of posts on some of the new features in C# 6.0, which was just released. In C# there is a very handy expression – typeof – that returns the Type of an object. For …

nameof expression Read More »

Tagged with: ,

This is one of a series of posts on some of the new features in C# 6.0, which was just released. The ability to format strings in .NET is straightforward, and fairly powerful (ignore the line breaks): string value = …

String interpolation Read More »

Tagged with: ,

This is one of a series of posts on some of the new features in C# 6.0, which was just released. When catching exceptions in code, you can have a different catch block for different types of exceptions: try { …

Exception filters Read More »

Tagged with: ,

This is one of a series of posts on some of the new features in C# 6.0, which was just released. Expression bodies let you use lambda-style expression declarations for methods and properties. So, instead of: public int Add(int x, …

Expression bodies on properties and methods Read More »

Tagged with: ,