Tag Archives: .net

C# 6.0 await in catch/finally

Advertisement from Google C# 6.0 become more asynchronous-friendly than before. Finally, you can use await keyword in catch and finally blocks! Here is example: class Program { static void Main(string[] args) { do { Console.WriteLine("Before caller " + Thread.CurrentThread.ManagedThreadId); CallerMethod(); Console.WriteLine("After caller " + Thread.CurrentThread.ManagedThreadId); } while (Console.ReadKey().Key != ConsoleKey.Q); } public static async void CallerMethod()… Read More »

[Raspberry Pi 2] Create C# Background Application for Windows 10 IoT Core

In this article,  we will see how to create simple Web Server for Raspberry Pi 2 running Windows 10 IoT Core. Because it is a Web Server we don’t need UI for this application, we can run it in headless mode. Open Visual Studio 2015 RC and create Windows IoT Core Background Application solution. Now… Read More »

[vNext] ASP.NET 5 Automatic Migrations with Fluent NHibernate

As I said in the previous article, I am gonna tell you about Automatic migrations with NHibernate and Fluent NHibernate in ASP.NET 5 applications. Automatic migrations is a really powerful feature, but you should be also really careful with it. Sometimes it might corrupt your schema or even data. Now back to ASP.NET 5 and… Read More »

C# 6.0 Detailed Overview Of The New Features

C# 6.0 has a lot of great new features, which save developer’s time and make code more clean and short. At the conclusion of the C# 6.0 series let’s go through the whole list of the new C# 6.0 features again (all titles are active). Each article contains detailed explanation of the particular feature with resulted IL… Read More »

C# 6.0 Exception Filters. try catch when

Exception filters is a new C# 6.0 feature. Visual Basic.NET and F# have this functionality for a long time. That is because exception filtering was implemented in CIL but not in C#. Now, this technique available for us. That’s how you can use it: try { Method(); } catch (Win32Exception ex) when (ex.NativeErrorCode == 0x07) {… Read More »

C# 6.0 Auto-Property Initializers

The next new feature of the C# 6.0 is auto-property initializers and get-only auto property. The main problem that they suppose to solve is immutable type declaration. Before C# 6.0, if you want to create immutable type with properties, you have no possibility to use auto property: public string Property { get; set; } So, you… Read More »

C# 6.0 Null Propagation Operators ?. and ?[]

C# 6.0 introduced two new null-propagation operators: ?. and ?[]. They will make null reference check much easier. In this article, we will see how they work and how they implemented internally. We all know about NullReferenceException and how to avoid it in our code. We just need to check everything for null before accessing some fields\properties\methods. Null… Read More »