Code4IT

Tag – .NET

15 posts tagged with ".NET" (See all tags)

Enum.HasFlag performance with BenchmarkDotNet

I've recently published two articles about some of the things you probably didn't know about Enums. I had too much to write that I split the original article into 2 parts: here's the first part and here's the second. In both articles I talked about…

Cool validation with FluentValidation

Needless to say, validating inputs is important. Invalid inputs may break your application and bring your system to an unstable state. If you are working with Web API or MVC pages, you are probably used to validation attributes within the definition…

Dependency Injection lifetimes in .NET - my epiphany

I'm pretty sure you already know what is Dependency Injection (shortened to DI) and why you should implement it in your applications. Just as a recap, DI allows you to define an association between an interface and a concrete class, so that when…

Logging with Serilog and Seq

One of the most important things to consider when developing and application is logging: not only it is useful for tracking errors and check if the system works correctly, but also it helps you with additional info about the status of the application…

First steps with asynchronous programming in C#

Asynchronous programming is a HUGE topic. That's why I'm not gonna talk of everything (even because I'm still learning). I've always seen it as a difficult topic, and I thought it was kind of useless to know and implement it. But I was wrong: it's…

How to get video details from YouTube with .NET Core 3

I have already talked about how to retrieve a list of YouTube videos by its channel ID. Now it's time to check the details of a single video. Let's say that you like a song, you listen to it at least 2 times a day and you want to download its…

How you can create extension methods in C#

Probably you have already heard of extension methods: those are C# methods used to add new functionalities to an existing class. This functionality is available since C# 3.0, so it's largely used and well documented. The basics of extension method…

Few tips for performance optimization

When talking about must-have for websites, performance is one of them. Why is it important? And how can you achieve it? 3 seconds are too much Loading time for a web page is crucial, especially in mobile. More than 50% of mobile users abandon a…

A recap of my 30ArticlesForNovember

For this November I decided to share each day an article on Twitter. I did it for simple reasons: share great content with the Twitter community recognize author's work by sharing and promote it discover new things and see the world from a different…

C# sorting - a subtle mistake

Recently I've learned a funny (ehm...) thing. The guilty It isn't true that the inverse of a negative number is a positive number. Or, equally, that (x < 0) => (-x > 0). You could say «Hey, -(-5) == 5». Yes, that's true. We can test it this way: But…

Solving type or namespace not found in .NET Core

Something strange happened today. I've developed a Class Library in .NET Framework and I tested it with the related test library. So I've integrated the library into another project. Everything was fine, I used that library without problems. But…

Few things from .NET Conference Italia 2018

Friday, October 26th, 2018 I attended the .NET Conference in Milan, Italy. It was an event organized by ASP Italia, with the sponsorship of Microsoft and Icubed. The conference was about the news in the .NET world: .NET Core 2.x, Azure, C# 8 and…