C# 7 Series, Part 8: “in” Parameters

C# 7 Series Part 1: Value TuplesPart 2: Async MainPart 3: Default LiteralsPart 4: DiscardsPart 5: Private ProtectedPart 6: Read-only structsPart 7: Ref ReturnsPart 8: (This post) “in” Parameters Background By default, method arguments are passed by value. That is, arguments are copied and passed into the method. Therefore, modification to the argument inside the…

0

C# 7 Series, Part 7: Ref Returns

C# 7 Series Part 1: Value TuplesPart 2: Async MainPart 3: Default LiteralsPart 4: DiscardsPart 5: Private ProtectedPart 6: Read-only structsPart 7: (This post) Ref Returns Background There are two ways to pass an value into a method: Pass by value. When an argument is passed into a method, a copy of the argument (if…

0

C# 7 Series, Part 6: Read-only structs

C# 7 Series Part 1: Value TuplesPart 2: Async MainPart 3: Default LiteralsPart 4: DiscardsPart 5: Private ProtectedPart 6: (This article) Read-only structs Background In .NET world, there are two basic types: reference types and value types. To be short, Reference types are classes that can be inherited/extended, when passing reference type objects, a “pointer”…

2

C# 7 Series, Part 5: Private Protected

C# has several accessibility modifiers, public, internal, internal protected, and private. Public: The member declared with this accessibility can be visible within the assembly containing this member, or any other assembly that references the containing assembly. i.e., access is not limited. Internal: The member declared with this accessibility can be visible within the assembly containing…

10

The Asynchronous Programming Models

An important new feature of C# 5.0 that comes with Visual Studio 11 is the async and the await keywords. They are syntactical sugars that simplifies the construction of asynchronous operations code. When the C# compiler sees an await expression, it generates code that automatically invokes the expression asynchronously, then immediately return the control flow…

1

Why no ForEach method on IEnumerable interfaces

I was asked many times recently regarding this topic, why not Microsoft introduce an extension method ForEach() on interface IEnumerable<T>? The answer is: "No, and never". Here are some strong reasons to not bring this extension method on IEnumerable. I will be discussing the following design considerations in this post. Design pattern Consistency Runtime behavior…

6