Visual C# Community Content |
| Justification for Names and Optional Parameters Bill discusses many of the ways where named and optional parameters constrain future component releases and complicate code understanding. You’ll learn how to best avoid these pitfalls in your own code and a little about why this feature was added as late as it was in C#’s evolution. | |
| LINQ and Productivity Since its introduction in C# 3.0, LINQ has changed the paradigms many C# developers use to create software. However, it seems that there’s still a large segment of the C# developer community that hasn’t yet fully adopted it. A reasonable investment in learning the toolset pays off heavily in programmer productivity, both for you, and the rest of your team that will read your code and extend it in the future. | |
| Async Programming in Visual Studio 2010 The latest MSDN magazine (Oct 2011) features three articles on the upcoming language and library features that support asynchronous programming. Those articles and the recent Visual Studio 11 CTP are great ways to learn about these new features, and grow your skills in async programming in C#. | |
| There Be Dragons It has often been written that declarative programs specify what you want, where imperative programs specify how you want it done. Mixing these concepts incorrectly can cause serious problems. Bill Wagner shows why, and what you can do about it. | |
| Introduction to Nullables Nullable value types provide consistent semantics around the concept of a null, or missing, value. Learn how they work and how to use them. | |
| Allocation of Disposable Members In all your types, there is a period of time when the objects have been allocated, but are not accessible to your program: during the time constructors execute. That is an important window to examine for resource leaks. Anything that gets allocated during construction cannot be freed using the standard .NET Dispose() pattern. Calling code does not have a reference upon which to call Dispose(). You need to modify your API, or defensively code your constructor to ensure that those issues do not occur for your types. This article shows two techniques to accomplish that. | |
| Concurrent Collections in the .NET Framework 4 Each new release of the .NET Framework adds features concentrated on challenges that are relevant to programmers today. The .NET 4 Framework adds a new namespace with collections that make it easier to write multi-threaded programs that share data between threads. Specifically, the concurrent collections do much of the work needed to implement a producer / consumer idiom in your applications. People have created multi-threaded programs before .NET 4, but these new collections mean the framework does more of the work and you can do a bit less. Alexandra Rusina, a programmer writer at Microsoft, wrote an introduction to the collections in the System.Collections.Concurrent namespace as a part of her parallel programming series. In this article, I’ll go a little deeper into the design of these collections. | |
| Mixing LINQ Providers and LINQ to Objects Bill Wagner: Some code I was writing for Azure gave me an excellent opportunity to discuss the differences between IEnumerable<T> and IQueryable<T> and explain many of the terms you’ll see in literature about LINQ providers. Understanding these issues will help you leverage both types to the fullest. | |
| Implementing Dynamic Interfaces Bill Wagner looks at the ability to build types whose public interfaces change at runtime based on how you use these types. C# provides that ability through dynamic, the System.Dynamic.DynamicObject class, and the System.Dynamic.IDynamicMetaObjectProvider interface. | |
| Back to Basics: Tips for greater developer productivity Visual Studio 2010 is out, and this is a good time to look at some of the default behavior in Visual Studio, and the quickest path to modifying those defaults to suit your (or your company’s) standards. After all, Visual Studio is not custom software for you or your organization. Instead, it contains many features that enable very rich customization. | |
| Use Optional Parameters to Minimize Method Overloads C# now has support for named parameters at the call site. That means the names of formal parameters are now part of the public interface for your type. Changing the name of a public parameter could break calling code. That means you should avoid using named parameters in many situations, and also you should avoid changing the names of the formal parameters on public, or protected methods. Of course, no language designer adds features just to make your life difficult. Named parameters were added for a reason, and they have positive uses. | |
| System.Collections.Generic.SortedSet: who needs another collection anyway? The .NET 4.0 library includes an additional collection class: The SortedSet<T>. At first glance, it doesn’t seem to provide anything new. You may wonder why we need yet another way to store objects. In this article, I’ll explain the drivers behind creating a new collection type, how the SortedSet<T> stores its objects. | |
| Tuples, Anonymous Types, and Concrete Types The release of .NET Framework 4.0 adds Tuples to the base class library. One challenge for C# developers is that Tuples serve similar purposes to Anonymous Types. It can be a challenge to make the best choice between those two solutions. In this article, I’ll look at some of the differences, and explain when I choose which solution. I’ll also discuss some of the situations that indicate you should avoid both Tuples and Anonymous types in favor of types you declare. | |
| Dynamic Method Bags The new dynamic features in C# 4.0 are usually discussed as an interop feature. You can write code using dynamic objects to call libraries defined in IronPython, or IronRuby, or COM objects. Just because a feature was defined for one use doesn’t mean that’s all it’s good for. I work with dynamic typing to explore new ways to solve problems without ever leaving C#. In this article, I’ll show you a bit of C# trickery that combines generics, expression trees, and dynamic to create a method bag. | |
| Understanding Delegates Developers are often confused about why the compiler cannot convert a lambda expression to a delegate. After all, the compiler converts lambdas to delegates in every LINQ query expression, in APIs used with the Task Parallel Library, and many other locations throughout the framework. In this article, I’ll explain why this doesn’t work, what you can do about it, and why it works in many other libraries. | |
| Local Type Inference, Anonymous Types, and var Of all the features in C# 3.0, local type inference is generating the most questions and misunderstanding. Read this article to quickly come up to speed on this important subject. | |
| Named Parameters In this article, I’ll discuss C# 4 features for named and optional arguments, and explain some of the subtle design decisions that enabled the team to add these features with a minimum of impact on existing code and existing developer expectations. | |
| Create Mixins with Interfaces and Extension Methods Learn about mixins, small utility classes that define some useful functionality which will usually become part of something larger. |
| How to detect and avoid memory and resources leaks in .NET applications By Fabrice Marguerie | |
| A Flexible Data Transformation Architecture Leveraging Dynamic Compilation By Joshua Greenberg, Ph.D. | |
| Inferred Typing with Factory Methods as Extension Methods By Peter Ritchie | |
| Deep Dive on Extension Methods By Thomas Lebrun | |
| Lazy Computation in C# By Tomas Petricek | |
| Multicast Delegate Internals By Mark Michaelis | |
| Reducing code-bloat with anonymous methods By Peter Ritchie | |
| Custom Iterators By Bill Wagner | |
| Protecting Intellectual Property with .NET Obfuscation By Eran Dror | |
| Solving Combinatory Problems with LINQ By Octavio Hernandez |
![]() | Bill Wagner, SRT Solutions co-founder, is a recognized expert in software design and engineering, specializing in C#, .NET and the Azure platform. You can connect with Bill through his blog on the SRT Solutions website. |