If you are old enough to have experience in .net framework (and I hope you do, otherwise I will feel really old myself!), there is a high probability that you were concatenating directory paths wrong all the time! And that’s all because some time ago, somebody at Microsoft had, let’s say, not a best idea :P.Continue Reading
[C#] How to read an API date field as UTC?
Dealing with dates in different time zones is a thing that requires some attention 😉. Today I want to show you a quick trick you should make when reading a date. And by that, I mean getting the date from an external source (ex. some IoT stuff or a REST API).Continue Reading
How to turn on C# 8 Nullable Reference Types
Nullable reference types? What’s that?
The hottest novelty of C# 8 is almost as hot as gossips about Bradley Cooper and Lady Gaga affair… Or maybe nullable reference types are hotter? Hard to say. Never mind, I wrote about it once when everything was just an assumption. Now, we finally can turn this feature on and dive into some details 😊.Continue Reading
Cannot implicitly convert type ‘Abc<Derived>’ to ‘IAbc<Base>’ – Contravariance vs Covariance – part 2.
Today I will write about the way variance (<in T> and <out T>) influences type checking in C#. Yes, the fact that one type can be passed to a generic method that requires another type, depends on these 2 small keywords we write before ‘T’ (or whatever ?) in interface header. BTW this article is the continuation of my previous post that makes a dummy introduction to the variance – if you haven’t seen it, then you should :P. Not because I wrote anything important there, but because my google analytics statistics will grow. So as you can see – it’s worth it :P.Continue Reading
<in T> vs <out T> – Contravariance vs Covariance – (the easier) part 1.
Have you ever seen these mysterious ‘in’ and ‘out’ keywords in generic interfaces’ definitions? If so, you’ve probably already checked what it means, but if not… You better read this and the next post (I promise, I will write it soon, not like always :P). So today we will talk about the basics of variance in our own generic interfaces.Continue Reading
Entity Framework .AsNoTracking() – why & how (EF and EF Core)
AsNoTracking() is a powerful method from DbExtensions class. And for sure – the method you should know and use ?. Continue Reading
() vs new ‘IEnumerable’ () – what’s better?
Reading Microsoft documentation when we have all that stackoverflow questions with answers usually seems a waste of time. And as a typical, lazy programmer I admit that (much too often) I agree with that sentence ?. But today I decided to check how Enumerable.Empty<T>() works and wasn’t satisfied with the knowledge I got. I started digging a little bit deeper and wasted some of the precious beauty-sleep time so if you want to know what’s happening when you add an element to an empty collection, let me tell you a story of today’s night.
No, not that story, you sick head! Continue Reading
C# 8 features – part 3 (Index type, Recursive pattern, tuned Switch expression => recipe for getting new friends)
This is the last post about C# 8 planned features and today I will write about Index type, recursive pattern and changes in switch construction. I will also teach you how to make new friends while programming. I hope you will not argue, that reading this post will pay off ;). Continue Reading
C# 8 features – part 2 (async method with yield return)
Microsoft promised us another great feature in C# 8 – async streams. And believe me or not, it was first discussed in… 2015! In this short post I will try to explain the idea and purpose of this new C# 8 planned feature. Continue Reading
C# 8 features – part 1.
If you were online at least once in the previews week you probably noticed the biggest announcement from Microsoft! Yeah, everybody is talking about C# 8 planned features. And because the news is literally everywhere, I gave up and decided not to repeat what everybody already read. But that decision is no longer valid because back THEN (which means – yesterday or so) my pet project wasn’t so nasty and I wasn’t so stuck in the middle of some stupid, trivial task that seems to be unable to accomplish… So yeah, I changed my mind, I will wrote about C# 8, just to avoid touching (for at least a day 😉 ), the disaster I programmed :D. No, it’s not procrastination, not at all! ?