Skip to main content

csharp

The right way to rethrow an exception in C#

All programming languages have gotchas to trip you up, and C# is no exception. Today, let’s check out the subtle (but significant) difference between “throw” and “throw ex”.

What is the opposite of Any in LINQ?

One of the many nice functions in LINQ is a single word that iterates through a collection, returning true if at least one item in the collection matches the condition you specify. But what’s the opposite of the Any keyword in LINQ?

Using Attributes in C#

Ever thought it’d be convenient to attach metadata to your code at design time, then read it at runtime? Attributes let you do just that - to methods, classes, tests, enumerations, and more. Use reflection to read them at runtime and take some action. Here’s a few examples for the uninitiated…