In C# 7 there the new feature called Local functions in C#. Basically Local functions allow one to write a function within the body of another method or function. It comes in handly in the case lets say you are creating a helper function that are mostly just used in one class or where the […]
In C# 7 there are Expression Bodied Accessors which allows you to write getter and setters somewhat more functional way, somewhat lambda’ish. Let me show you an example. You may remember the old way of writing getter and setters like below. Pre Expression Bodied Accessors Getter and Setter
1 2 3 4 5 6 7 8 9 |
public class Automobile { private string _brand; public string Brand { get { return _brand; } set { _brand = value; } } } |
Expression Bodied Accessors in C# 7 […]
In C#7 there are Digit Separators and Binary Literals which were added. One may wonder what these are? Basically you can replace long number values with underscore (_) such that code readability is improved. Let me give you couple of examples of it to make it clear.
1 2 3 4 5 |
//old way of var myBigNumber = 12345678901234567890; //new way with digital separators var myBigNumberNewWay = 123_456_789_012_345_678_90; |
Neat but it doesn’t end there you […]
So one may ask “What is the advantage of using discards in C#?”, and if you don’t know what discards are you can check out the MS C#7 Documentation about it. Basically discards are variables in simple terms, and the declaration of the variable as a discard is by assigning it the underscore (_) as […]
Some may wonder what is the difference between ValueTuple and Tuple that was released in C# 7, and you might say I have been using Tuples for a while now. Whats the difference? Some of you will remember with code like below that showcase the use of ValueTuple since .NET Framework 4.7
1 2 3 4 5 6 7 |
public Tuple<string, string> GetUserName(int userid) { var firstname = db.GetFirstname(userid); var lastname = db.GetLastname(userid); return new Tuple(firstname, lastname); } |
In order […]
One of the easiest cloud design pattern that one can try out is the Retry Pattern. I wanted to show how to use an Retry Pattern using Polly in C# as a example. So what does the Retry Pattern achieves? Problem Statement – What is the issue the pattern solves? When building applications you always […]
In this blog post I wanted to show how one can use C# or Python to view the serial numbers of a X509 certificate. The serial number can be used to identify the certificate that one plans to use in their C# application, lets say for mutual authentication to another service. Why use X509 Certificates […]