Functional F# that slowly appears in C#

Functional F# that slowly appears in C#
Rate this post

For some reason, we often do not use this functionality. Maybe we haven’t got used to it yet. And sometimes we use it, having no idea that this is the functionality from F#.

Before reviewing it, let’s quickly run through the most interesting features that appeared in different versions of the language. Note that each time a new version of the language comes out with a new version of Visual Studio. For someone, this may be obvious, but even for developers who have worked with C# for several years, this may turn out to be a piece of news (not everyone takes notice of it).

Read More

Configuration Comparison of Dependency Injection Containers (IOC)

Configuration Comparison of Dependency Injection Containers (IOC)
4.7 (93.33%) 3 votes

I have often questioned myself which IoC container would be suitable for this or that project best. Their performance is only one side of the coin. The other side of the coin is the simplicity and speed of learning. So, I decided to compare the following containers from this point of view: Autofac, Simple Injector, StructureMap, Ninject, Unity, and Castle Windsor. In my opinion, these are the most popular IoC containers. You can find some of them in the list of the top 20 NuGet IoC packages. Also, I added a few containers based on my personal preferences. I really like Autofac and when writing this article I was reinforced in my choice in most of the cases.

In this article, I will describe the basics of the IoC containers, such as configuration and logging of components. I also want to compare the management of lifetime scope and advanced features. Code examples can be found in the LifetimeScopesExamples GitHub repository.

Read More

Tricky Questions about C#

Tricky Questions about C#
4 (80%) 2 votes

Some questions may seem too basic, but they still contain tiny tricks. Sometimes even a simple question may nail to the wall. These questions will be useful to all who study the language.

So, let’s start!

1. What will be the result of execution of the following code?

Read More

Another Way to Localize Application

Another Way to Localize Application
3 (60%) 2 votes

I would like to introduce a simple way to localize applications. I do not like the standard mechanism with resource assemblies for the following reasons:

  1. When receiving a value of a localized string in the code, I would like to rely on OOP and compiler prompts. It is very unpleasant to generate a project on Friday evening, and on Saturday morning, to get a call from QAs working overtime that someone inattentive wrote GetResource (“asdf”) instead of GetResource (“assf”). Thus, now something crashes or is displayed incorrectly. In addition, the project is to be “put to print” on Monday… Read More

Preparing for Exam 70-483: Programming in C#

Preparing for Exam 70-483: Programming in C#
5 (100%) 1 vote

During preparation for exam 70-483, I found lots of websites containing links to various manuals that helped me a lot. But what really helped me was the memo notes I composed for myself and which I’d like to share in this article. I do not target to provide a detailed description of C#, I just want to refresh your memory and to highlight certain aspects of C#. If you are not familiar with some aspects, it means you have gaps in your knowledge that should be eliminated. Read More

How Generics save from Boxing

How Generics save from Boxing
1 (20%) 1 vote

At the method input, we often perform a null test. Someone makes the test as a separate method, so that the code looks cleaner, and gets something like this:

The interesting thing about this test is that I see a frequent use of the object attribute, though you can use generic. Let’s try to replace our method with generic and compare performance.

Read More

Signals in C#

Signals in C#
3 (60%) 1 vote

 

Currently, the thread synchronization in С# causes some difficulties, in particular, when passing synchronization primitives between the objects of your application and supporting them in the future.

The current model with Task and IAsyncResult, as well as with TPL, solve all issues through a proper design. However, I would like to create a simple class that allows sending and receiving signals with a thread lock. Read More

Drilling Down the Visitor Pattern

Drilling Down the Visitor Pattern
Rate this post


Recently, I have often had to use the well-known Visitor pattern. I used to ignore this pattern and thought that it simply complicates the code. In this article, I will share my thoughts about this pattern. We will talk about pros and cons, as well as what tasks it helps to solve and how to simplify its use. The code will be in C#.

Read More

.NET Managed + C Unmanaged: What’s the Cost?

.NET Managed + C Unmanaged: What’s the Cost?
Rate this post

When I was programming in C#, I used to send all recursive tasks to an unmanaged C code, since the .NET performance was problematic. And now, looking back at my past experience, I think of the benefits of such code division. Do I really benefit from it, and if yes, how much? What is the best way of building API with such approach? Read More