C# 7 Series, Part 9: ref structs

Background In the previous posts, I have explained many new C# features, each of the feature is introduced to either enhance the language, or solve issues. Specifically, I explained value types and reference types, pass parameters by value, pass parameters by reference,…Read More »

C# 7 Series, Part 8: “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 method body does not affect the original value. In most of the cases, modifications are unnecessary.…Read More »

C# 7 Series, Part 7: 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 it is a value type) or a copy of the argument reference (if…Read More »

C# 7 Series, Part 6: 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” is passed; value types are structs that cannot be inherited/extended,…Read More »

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:…Read More »

C# 7 Series, Part 4: Discards

Sometimes we want to ignore values returned from a method, especially those out arguments, a typical example is to check whether a string can be parsed to another type: bool parsedValue;if (bool.TryParse(“TRUE”, out parsedValue)) { /* Do your stuff */ } Here…Read More »

C# 7 Series, Part 3: Default Literals

C#’s default keyword has two kinds of usages: one is to label the fallback branch of the switch…case structure (for any path that does not fall into the case conditions); another is to represent the “default” value of a type. I will…Read More »

C# 7 Series, Part 2: Async Main

As you may know, there are two kinds of the programs the C# language can build. One is a program with an entrypoint so that the Operating System can load the program and execute it from the entrypoint; another is the program…Read More »

C# 7 Series, Part 1: Value Tuples

Starting today I will start a new C# 7 series, to introduce new language features of C# 7+ features. Please note that I am not saying C# 7.0, I am saying C# 7 plus, because there will be minor language versions (like…Read More »