C# Performance Tips

Check List has items List.Count() vs List.Any() Stopwatch watch = new Stopwatch(); List < string > strs = new List < string > () { “Akshay”, “Patel”, “Panth”, “Patel” }; watch.Start(); if (strs.Count() > 0) {} Console.WriteLine(“List.Count()-{0}”, watch.Elapsed); ——– watch.Restart(); if (strs.Any()) {} Console.WriteLine(“List.Any() – {0}”, watch.Elapsed);   Loop on items in a list Array.Length vs var i […]

Entity Signal – Real Time Entity Framework (EF) and ASP.NET core

What is Entity Signal? Entity Signal allows you to connect to Entity Framework through SignalR and get updates on subscribed data in real time. This lowers the number of refreshes done by the user and ultimately allows you to do more with fewer servers. It is also requires minimal changes, so you can make realtime apps about as […]

Thread Safe Concurrent Collection in C#

Concurrent Collection The .NET Framework 4 brought the System.Collections.Concurrent namespace. This has several collection classes that are thread-safe and scalable. These collections are called concurrent collections because they can be accessed by multiple threads at a time. The following are the concurrent collection in C# − Sr.No Type & Description 1 BlockingCollection<T> Bounding and blocking functionality for any […]