X

C#

Ref returns and ref locals in C# 7.0

C# 7.0 introduces ref returns and ref locals. Main goal of these new features is to make it easier for developers to pass around references to value types instead of copies of their values. This is important when working with large data structures that are implemented as value types. This blog post shows how to use ref returns and ref locals in Ć#.

New expression bodied members in C# 7.0

Although expression bodied members have been supported in C# few years there were still room for some new ones. C# 7.0 introduces expression bodied constructors, destructors, getters and setters. This blog bpost goes through all these new expression bodied members and shows how to use them. Also a little peek behind the compilator curtains is made.

Internals of tuple literals

My last post about tuple literals gave brief intorduction to these. This post goes to internals of tuple literals, peeks behind the compiler and shows what happens with tuple literals internally. This post is for developers who are new to tuple literals and want to gain more deep understanding of these.

Are lock and Monitor the same in C#?

Working on some threading stuff I stumbled upon some discussions about lock and Monitor. Some say they are different and some say they are the same. I took few minutes of time to make some simple experiments with both of these. This blog post shows what C# compiler does with lock statement. As I had to use also Monitor class I added one example here how to use it instead of lock.

Deep dive to async Main

C# 7.1 introduces asynchronous Main method for console applications. It helps us to get rid of some ugly code to await for asynchronous methods. If Main method of console applications is application flow controller that makes multiple calls to asynchronous methods then async Main leads us to much cleaner code. This blog post is my deep dive to async Main.

Converting multiple C# enums to JavaScript

My last solution to turn C# enums to JavaScript was simple but needed some additional work to support multiple enums better. After some playing with different approaches I found simple one that works okay for me. This blog post describes my simple solution that turns multiple C# enums to JavaScript with one shot.

Local functions in C# 7.0

One of new features of C# 7.0 is support for local functions. Local functions are methods that are defined inside other methods to simplify more complex code and by example to support local recursion. This blog post shows how to use local functions in C# 7.0 and gives some advice in context of technical design of code.

Throw expressions in C# 7.0

C# 7.0 introduces throw expressions. We can add exception throwing to expression-bodied members, null-coalescing expressions and conditional expressions. This blog post introduces throw expressions, demonstrates how to use them and also provides a peek behind a compiled throw expressions.

Tuple literals in C# 7.0

C# 7.0 brings some new features to tuples and with code editors that support these new features we can use tuples with named members instead of names like Item1…ItemN. This blog post goes through practical example that demonstrates how to move on classic method that returns multiple values to new tuples.

Out variables in C# 7.0

C# 7.0 brings some features to out variables. These new features help us write cleaner code and handle out variables better. This blog post provides samples of these new features in C# 7.0 and as a surprise it also demonstrates what compiler is doing with these new features.