C# 3.0 – Lambda Expressions

"A lambda is an inline expression or statement block with a concise syntax that can be used in C# 3.0 and later wherever a delegate type is expected" . In a certain way we can consider Lambda Expressions as an evolution of the anonymous methods. Look the examples below, at first sight the syntax looks […]

C# 3.0 – Object and Collection Initializers

With C# 3.0 you can initialize objects specifying the values of their visible properties and/or fields enclosed between brackets. The syntax is as easy as open the brackets and provide a list of name/value pairs separated by commas with all the properties/fields you want to initialize, the value of the field can be an expression […]

C# 3.0 – Automatic Properties

Properties are widely used in .NET applications, but it’s also very common to declare their get/set accessors without any business logic, just with the minimum code to return and set the value of the property. Now it’s possible to reduce the minimum code you need to type in order to have a property up and […]

C# 3.0 – Extension Methods

Extension methods are a very cool feature. They are special static methods that can be used as if they were instance methods. What does it mean from our developer perspective? That we can simulate we add new methods to existing types. It's quite common to find an existing class we want to extend with some […]

C# 3.0 – Implicitly Typed local variables

C# 3.0 introduces a new way to declare variables where the type applied can be inferred from the initializing expression. This is done using the keyword "var" instead of specifying explicitly the type. For example: var text = "hello world" // type: string var index = 12; // type: Int32 var people = new List(); […]