Tagged: C#

Method invocation in C# is tricky

A few days ago, a friend o mine had a very interesting issue with C# code he had written. Let’s take a look:     There are two overloads of the generic method called Bar. The first one accepts a...

To var or not to var?

Recently, I had quite an interesting discussion about var keyword in C#. Basically, my interlocutor tried to convince me that using var we drastically reduce code readability, so we should only use that together with anonymous types. He also mentioned...

private protected in C#?

A few days ago I watched a very interesting talk from NDC given by Jon Skeet, Kathleen Dollard and Rob Conery. Around 41:15 minute Kathleen said something very interesting about protected internal: […] if you say protected internal then that...

CodeTip #7 – Aliased generics in C#

It’s pretty funny to me when you think that you know some programming language quite well and suddenly you find out some feature, you’ve never heard before. I mean at all. That’s exactly what happened to me yesterday. Let’s see...

What lies beneath async/await in C# ?

Nowadays, asynchronous programming isn’t something unusual. We all know that when it comes to do some I/O operations or HTTP request, we should do it async. Why? There’re several reasons but two most important  are: Efficiency. In many cases, the...

What are covariance and contravariance in C#?

Sometimes it happens that we use mechanisms/features of specific language without beeing aware of it. That’s fine, but if you’ll want to discuss your code in a future to the audience or coworkers, soon or later you’ll be forced to...

Func<‌T> vs. Expression<‌Func<‌T>>

A few days ago I was playing with Entity Framework when suddenly an Exception popped out on the screen:   Additional information: LINQ to Entities does not recognize the method ‚System.String GetFullName(User)’ method and this method cannot be translated into...