The curious case of strings in C#

Published by:

In the last article I tried to describe the difference between value types and reference types in C# and I received some interesting feedback from colleagues and former colleagues as well. And based on discussions I had, it makes a lot of sense to talk a little bit about strings. Strings are very strange, because they are a reference type but behave somehow similar to value types. So, there are some common misconceptions and misunderstanding when it comes to strings that I will try to clarify in this article. Continue reading

Reference types and value types in .NET

Published by:

Note: I also made a YouTube video on this topic with some more graphical representations of these concepts. You might want to check it out: https://www.youtube.com/watch?v=8Uf-ziPWbJQ

In .NET (and therefore C#) there are two main sorts of type: reference types and value types! Understanding these sorts of type is crucial in the .Net ecosystem and, more generally, in object oriented programming. There are some clear definitions of these concepts that anybody could learn fairly easy, but really understanding how reference types and value types work is sometimes a little bit harder. And I must confess that it took me some time to achieve a certain level of familiarity. Furthermore, if you really want to understand how reference types and value types work, you need to get your hands dirty an play around with them. In this article I will try to explain reference types and value types as good as I can, starting from some dry (but important) definitions that I will try to make more vivid using code samples. Continue reading

Sorting lists in C#

Published by:

Working with lists is something developers do almost everyday. One of the most common tasks when we think about lists is sorting them. Fortunately, sorting lists in C# is not very complicated when it comes to primitive types and strings, but are slightly more complicated when we create lists of our own objects. In this tutorial we’ll go through some of the common ways to sort lists in C#.

Let’s start with a short and simple example. Let’s assume that we create a list of names and we add some names to the list:


List<string> names = new List<string>();
names.Add("John");
names.Add("Dan");
names.Add("Zack");
names.Add("Cristina");

Continue reading

Middleware in ASP.Net Core – part II

Published by:

Few days ago I wrote a short tutorial about middleware in ASP.Net Core and I promised to continue the topic, since there are some concepts that I didn’t cover. In the mentioned first tutorial I tried to describe what a middleware pipeline is, why middleware order is important and the importance of the next() delegate. In the second part I will focus more on the Use()Run() and Map() methods that we can use when setting up the middleware pipeline of an ASP.Net Core application.

Technically speaking Use()Run() and Map() are extension methods on Microsoft.AspNetCore.Builder.IApplicationBuilder instances. If you look them up, you’ll see something like this: Continue reading

Thoughts about Cambridge Analytica

Published by:

There’s a huge scandal these days around Cambridge Analytica since The New York Times and The Observer reported on the company’s use of personal information acquired by an external researcher who claimed to be collecting it for academic purposes. In response, Facebook banned Cambridge Analytica from advertising on its platform. Reports also say that Cambridge Analytica CA worked for Donald Trump’s presidential campaign. That’s just to draw the context. As a last introduction note, I won’t make any comment on politics or legal aspects of this scandal! Continue reading

Middleware in ASP.Net Core – part I

Published by:

Middleware is a very important topic in ASP.Net Core since it enables you to add very important functionality, like adding necessary configuration to deploy ASP.Net Core and Angular together. But at the same time there are a lot of misunderstandings regarding middleware in ASP.Net Core among developers that are new to the platform. That’s why I think it’s a good start to highlight the most important concepts regarding middleware so that new developers can get started much quicker with ASP.Net Core.

The concept of middleware

I won’t try to give a real and exhaustive definition of middleware (you can find this on the Microsoft documentation). Instead, I will try to depict a picture of how middleware in ASP.Net cor relate to the application you’re developing. So let’s imagine that you already have an ASP.Net Core application that is hosted somewhere and I want to make a request to that application. So when I send my GET request, it will first hit Kestrel, the web server built into ASP.Net Core. For the request, that’s the entry point to the application. Continue reading

Deploy ASP.Net Core back end with Angular front end

Published by:

Single page applications (SPA) have become a standard in the web development world by now, reshaping the way web applications are designed. Traditionally a web browser (client) would send out a GET request to a server and the server would return an HTML page. Nowadays we have SPAs that rely on web APIs for data retrieval and that run like real applications in a browser. That’s why in the .Net ecosystem having  .Net Core web APIs with Angular 2+ front end is a common scenario and it might be useful to look into different basic deployment strategies. Before I go any further, I want to point out that this article is aimed for junior developers, developers that are new to the .Net ecosystem or for all those that are on their way to become software developers. Continue reading

Azure AD B2C vs Firebase

Published by:

Coming from the Microsoft world it was natural for me to immediately jump to Azure AD B2C when I needed to implement authentication in an Angular 5 application. However, things weren’t so rosy, so I had to look for alternatives after an entire day playing around with Azure AD B2C and so I met Google Firebase. And after more days of playing around and comparing pros and cons, I thought it might be useful for others to share some thoughts on these two products.

What was everything about?

I am currently working on a personal project that might be some day a consumer app. Since I like Angular a lot, it was a natural choice for me to use it for my front end work. The larger picture involves also a .Net Core API and all needed application layers. When I started to work on the front end, one of the first things I wanted to do is to implement authentication. Here it’s important to note that my project will hopefully be some day a consumer app. So that’s why I was looking at Azure AD B2C and not the (let’s say) normal Azure AD. Continue reading

Do you want to become a software developer? Here’s how!

Published by:

So, do you want to become a software developer and you didn’t graduate computer science? Do you feel that “your time has passed” and you still think that there’s a lot more to achieve? Well, this post is for you, so you might want to keep on reading! If you ask yourself if this is even possible, well…. yes it is! I’ve studied philosophy and theology and still I’m working for almost ten years in the IT industry, I’m playing around with code for around 2 years and now I’m a software developer. Is it easy? Not at all! Or it depends on what “easy” means for you. But it’s achievable and here are a few guidelines on how you can become a software developer.  Continue reading

Create your own reusable C# libraries targeting .Net Standard

Published by:

A while back I tried to “demistify” the main concepts around .Net Core, .Net Standard and .Net Framework, since there were (and still are) a lot of questions and concerns regarding these topics on social media. This time, I’ve decided to go one step further and show you all these concepts at work . This article is intended for beginner .Net developers or self-taught developers like me, which struggle to find a clear path in a jungle full of information that is not always accurate.  Continue reading