Kategori: C#

  • Visual Studio 2019, .NET Core 3.0, and C# 8.0

    This week it has been really fun being a .NET developer. Previews of Visual Studio 2019 and .NET Core 3.0 has been made available to the community, making it possible to try out the new upcoming features. I will not just repeat information that you can find on other sites, instead I will provide some […]

  • Cleaner Code with Command Query Separation

    What is Command Query Separation? The Command Query Separation (CQS) concept is a way to structure your code and methods. The idea is that a method may either be a Command or a Query but not both. It was coined by Bertram Meyer in his book ”Object Oriented Software Construction” from 1994. What identifies a […]

  • C# 8 and The Future of Null

    The nullable types If you have been coding C# for a while you have probably come across Nullable types (Microsoft link). A Nullable type is in instance of System.Nullable<T> where T can be any non-nullable value type (such as int, float, bool). An instance of System.Nullable<T> can represent any value of the underlying type T […]

  • A functional alternative to returning null

    Last week I wrote about alternatives to returning null. There was however one alternative that I left out, the Maybe functor. The reason I left it out last week was that I hadn’t had the time to read up on it properly. Now that I do have read up on it, and had some time […]

  • C# alternatives to returning null

    What is problematic with returning null? A common pattern, both in the code I am used to work with, and in parts of the .NET Framework, is to return null in methods if for some reason a valid return value is not available. One example of this is the Find method of List<T>: So, why […]

  • How to debug a Blazor project

    Why is debugging Blazor applications different from Angular or React? When you run a JavaScript framework, like Angular or React, the JavaScript code is available on the client-side. This makes it possible to use the built-in developer tools in the browser to inspect and step through the code. When running Blazor applications you execute a […]

  • How to consume a REST API using Blazor

    The RESTful service A couple of blog posts ago I wrote about how to design a REST API with ASP.NET Core and now I intend to show how to create a front end that can interface this service in order to create and remove products from the repository. To recap, the RESTful service was designed to […]

  • C# In-Memory File System

    Unit testing code that reads or writes to the filesystem can be difficult. One thing that can help is an in-memory file system that lets you emulate the actual file system just for testing purposes. This morning I stumbled across a blog post by Jason Roberts, a five time Microsoft MVP, freelance developer, writer, and […]

  • Blazor – first impressions

    What is Blazor? To quote the official Blazor homepage ”Blazor is a single-page web app framework built on .NET that runs in the browser with WebAssembly.” The natural follow-up question is then ”What is WebAssembly?”. From the official WebAssembly homepage we can read that ”WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based […]

  • How to design a REST API with C# in ASP.NET Core 2

    What is REST? REST is short for Representational State Transfer,  and is way to design web services. So called RESTful web services. Usually the RESTful service is accessible via a URI and HTTP operations such as  GET, POST, PUT, and DELETE are used to get or modify the data that is often stored in a […]