Assignment using Ternary Operator

Couple of days back, I happened to come across a question in StackOverflow. Question seemed pretty straightforward, but at the same time, interesting. How would one use ternary operator for assignment. For example, how would write following code using ternary operator. Obviously, following wouldn't work. One way to use ternary operator would using Action. But … Continue reading Assignment using Ternary Operator

Advertisement

C# 7.3 Features : Tuple Comparison & Generic Constraints

C# 7.3 is another minor roll-out that brings along with 'seemingly minor' improvement, but ones that definitely opens new opportunities. In this blog post, we will explore  two features that are introduced in 7.3 Tuple Comparison C# 7.x had already made tuple an immensely powerful tool with a variety of features, and the latest minor … Continue reading C# 7.3 Features : Tuple Comparison & Generic Constraints

Nominal Vs Structural Type System

Anonymous Types and Tuples might look very similar, but there is one significant difference which separates them. As always, nothing can be more explanatory than writing code. Consider the above code. What could be the output ? Are both false or are both true ? Interestingly, the output is as follows. Though syntactically similar, both … Continue reading Nominal Vs Structural Type System

Benchmarking Span<T> Performance

Span<T> is yet another addition to C# 7.x and is particularly useful in developing memory intensive applications.  So what is Span all about ?   As Microsoft describes it, Span<T> is a new value Type which enables the representation of contiguous regions of arbitrary memory, regardless of whether the memory is associated with a managed … Continue reading Benchmarking Span<T> Performance

Reference Semantics and Code Readability

One of the features Microsoft packed with C# 7.2 is Reference Semantics with Value Types. Though designed with the intention to improve performance by eliminating the need for copying (and thereby allocating memory) value types , I do have my reservations on the complexity it adds to readability of code for a programmer. Let's consider … Continue reading Reference Semantics and Code Readability