Your weekly dose of 5 Highlights Thursday is here, a list of information and links that you may find helpful in your Azure journey. Feel free to forward this along to anyone who you think may enjoy such sharing. 1. MVP TechBytes – Azure Governance and Compliance: Best Practices and Tools with Kazeem Adegboyega Join […]
In C#7 there is an enhancement in the main method Async Main in C# that will allow you to await in your main method. Let me show you an example of how it was in C#6 and then how it has changed in C#7. You will remember this most likely
1 2 3 4 |
static int Main() { return SomeAsyncCall().GetAwaiter().GetResult(); } |
One will need to […]
In C#7 there is an improvement on using out parameter. Some of you may remember writing code like below.
1 2 3 4 5 6 7 |
string hourString = "5"; int hour; if (int.TryParse(hourString, out hour)) { Console.WriteLine($"The hour is {hour}"); } |
The improvement that C#7 brings is you can now declare out variables in the argument list of a method call, rather than writing a separate declaration statement like below:
1 2 3 4 5 6 |
string hourString = "5"; if (int.TryParse(hourString, out int hour)) { Console.WriteLine($"The hour is {hour}"); } |
And it doesn’t end there […]
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 […]
In the second blog post series “Redis for .NET Developer” I will show how we will use C# to connect to Redis. If you want to learn how to install Redis, visit my previous post on Intro to Redis for .NET Developers – Installing Redis on Windows. We will be using StackExchange.Redis library to connect […]
I just got back from MVP summit from Seattle, and there were lots of new and cool stuff about the future of .NET and web development with vNext. I would strongly to suggest that you join the virtual developer Microsoft conference Connect(); http://www.visualstudio.com/en-ca/connect-event-vs On the 12th you will have keynotes from Scott Gu, Scott Hanselman […]
Here is a quick C# tip of counting up values of a Dictionary<TKey, TValue> where the values contains a List<T> using Linq. Lets say you have a Dictionary that contains Dictionary<string, List<Guid>> and you wish to find out how many items of Guid you have. You can easily do it by the Sum Linq aggregate […]