X

C#

Using var keyword in C#

Keyword var is cool thing we can use to make our code more readable for other programmers and why not - reviewers. But var can also be used to make our code difficult to understand. In this case, lte's say, we are overusing var. So, var is like wine - if one takes glass of it then everything is okay in the morning, but if somebody takes it couple of bottles then the morning will be awful. Or let's say - too much var will kill you?

Interface for Processes

I had to write one data import/export utility that moved data from one database to another. Once I was finished the first round of coding I found one thing that needed refactoring - the import/export process wasn't generalized. It was part of importer/exporter utility main class (it was console application). After some refactoring I got some common things to use in other tasks like this.

C# and Partial Classes

.Net 2.0 provided us with new feature called partial classes. Using partial classes we can use multiple files to keep the code of same class. Yes - we can put some methods to one file and the others to another file. Although partial classes may be extremely useful they can be also used to ruin system's technical design if developers don't know what happens behind the compiler.

Safe foreach loops with C#

This is rewrite of my old post about bullet-proof foreach loops. The post covers internals and functioning of foreach. It also shows how to write safe loops and how to modify collections that foreach is stepping through. This post is excellent reading for those who want to have better understanding of foreach loops.

Using Version Class

When dealing with version numbers we often need to convert them to string and vice versa. There is lot of code where versions are handled manually in code. I don't know why. But I know for sure there is class called Version and I'm sure this class will help us a lot. Let's see a little example.

C# and question marks

One cool operators that C# offers us is ?? But before ?? we should know what does ? after variable type name. So, let's take both of these question marks and let's see what they are. Also let's jump for a while behind compilator to see IL code that compiler produces.

Extension methods in C#

Extensions method introduced with C# 3.0 make it possible to “extend” existing classes with new methods without access to source code of those classes. This blog post is deeper technical introduction to extension methods for those who are making decisions about software design and architecture.

Automatic properties in C#

Automatic properties are supported by C# since version 3.0 and as developers we use them almost every day. Sometimes developers have questions about how automatic properties work and how to effectively use them. Also I bust some myths about automatic properties and go deep with internals.