Extension Methods

Extension Methods - metody rozszerzające, które pozwalają na wykorzystanie raz napisanego kodu w wielu miejscach bez naginania zasady DRY (Don't Repeat Yourself). Metoda taka musi być statyczna i musi być zarejestrowana w statycznej klasie. W ten sposób możemy bardzo łatwo rozszerzać operacje na podstawowych typach, jak również rozszerzać funkcjonalność typów pochodzących z zewnętrznych bibliotek. Załóżmy … Continue reading Extension Methods

Searching for a specified instance in List

Short post about searching List. There are 3 most popular methods: foreach, delegate and lambda expression. I will introduce all of them. Let's say that we have List which stores cars. Car has 2 properties - brand and model. We need to find "Car2Brand" car. You can use foreach: I don't like this method, because … Continue reading Searching for a specified instance in List

Interfaces. Do I need these?

My friend has asked this question one week ago. He was not able to understand the usage of interfaces in his small projects. I decided to explain it, but I knew that it would be a long journey, from the beginning to the end. FInally he got the idea. Today I will try to explain … Continue reading Interfaces. Do I need these?