Taswar Bhatti
The synonyms of software simplicity
Tag: C#

dotnet core with GenFu Couple of weeks ago I had to test out the performance of a third party product but in order to test we had to use a lot of logs that would feed into the system. The requirements was to pump out around 1000 logs per seconds and feed into the system. […]

Redis Hash Datatype are similar in C# world as Dictionary e.g Dictionary<string, string>. Just like in C# redis stores map of attributes using key value pair. One thing to note is in Redis a Hash both the field name and the value are strings. Therefore, a Hash Datatype is a mapping of a string to […]

Continuing on with our Redis for .NET Developer, the Redis String Datatype is also used to store integers, float and other utility commands to manipulate strings. Redis String Datatype using Integers In Redis float and integers are represented by string. Redis parses the string value as an integer and the neat thing about them is […]

Continuing our series on Redis for .NET Developer, we will be looking into the basic string datatype that Redis provides. First to be clear, Redis is more than just a string cache or to store your serialized objects, it is a data structure server, but nevertheless the basic understanding of using strings in Redis will […]

In the second blog post series “Redis for .NET Developer” I will show how we will use C# to connect to Redis. If you want to learn how to install Redis, visit my previous post on Intro to Redis for .NET Developers – Installing Redis on Windows. We will be using StackExchange.Redis library to connect […]

Here is a quick C# tip of counting up values of a Dictionary<TKey, TValue> where the values contains a List<T> using Linq. Lets say you have a Dictionary that contains Dictionary<string, List<Guid>> and you wish to find out how many items of Guid you have. You can easily do it by the Sum Linq aggregate […]

Here is a quick C# tip, when using string compare don’t use

use the Equals and StringComparison.InvariantCultureIgnoreCase enum.

The thing you need to note is which rules are appropriate current culture, the invariant culture, ordinal or another culture entirely. One can create the compare from StringComparer.Create(culture, true)

Here is another C# tip. Most of the time when you are trying to get a value from dictionary you would try to check if the key exist or not something like.

But one can use TryGetValue

The benefit of using TryGetValue is that the dictionary is synchronized, there is no race condition.

Here is a hint when using WPF and you may come into a situation where you want to databind an element to its Parent ViewModel. As an example lets say you have a view that is binding to ViewModel and inside your xaml you have a control that has DataTemplate The code Below we are […]

In C# there is a params keyword which allows a method parameter to take variable number of arguments. MSDN Some notes on param It must always be the last parameter in the function/method definition There can only be one params keyword in a function/method parameter signature Example:

But by changing it to params we […]