One interesting feature of delegates in C# is that it provide ways to attach / detach more than one methods that has method signature similar to the delegate declared and combine them together. This combining or attaching / detaching of methods to a delegate is called Multicasting. Behind the scenes: This multicasting is possible because delegates inherit from System.MulticastDelegate which in turn inherits from System.Delegate, which inherits from Object class. How to multicast: Multicasting can be done using += and / or -= operator. Here is an example that demonstrate use of += and -= to multicast delegates. private delegate void Greetings(); static void Main(string[] args) { SayHello(); Console.ReadLine(); } public static void SayHelloToScott() { Console.WriteLine("Hi Mr. Delegate, from Scott"); } public static void SayHelloToAlex() { Console.WriteLine("How about a coffee? from Alex"); } public static void SayHelloToJasmine() { Console.WriteLine("Hi delegates, from Jasmine"); } public static void SayHelloToJsinh( » Read more

 Jsinh        

I had a weird experience before few days, I definitely knew how to solve the problem and I am sure it is the right way to do it. Thinking it would not be any different to map a datatable to POCO class(es) using Automapper. But it didn't turned out to be completely true. I have been playing with Automapper for couple of years now in my day-to-day work, but I stumbled a bit this time. Situationally, I was not able to conclude the problem with a working solution at that moment, thus I would take this opportunity and write about it so anyone out there who is facing same or similar problem can find their answers. Problem Data filled into a datatable was expected to be converted to Json object. If the datatable contains more than one row the resultant Json should have list of Json objects for each » Read more

 Jsinh        

There will be lot of situations when you have introduced boolean expressions in your code and in good times you might have also combined more than one boolean expressions to control your program flow. Boolean Expression Any expression that can produce a boolean result can be considered as boolean expression. The end result will be boolean, i.e true or false. For example: x == y You can use Greater than >, Smaller than <, Greater than or equal to >=, Smaller than or equal to <=, equal to ==, Not equal to != equality operators to create a boolean expression. Combining Boolean Expression You can combine more than one boolean expressions using OR - ||, AND - && and EXCLUSIVE OR - ^ boolean operators. Short-circuiting - OR (||) boolean operator The OR - || boolean operator when applied returns true when any one of the two operand (or boolean expression) or both operand evaluates » Read more

 Jsinh        

One interesting feature that was introduced since .NET 4.0 was AppDomain.FirstChanceException FirstChanceException MSDN: Occurs when an exception is thrown in managed code, before the runtime searches the call stack for an exception handler in the application domain. This means that whenever an exception occurs in your managed code, all subscribers of above mentioned event will be notified with exception details. It is called first chance because this event is notified to the debugger or subscribers even before the actual program gets it. Event before Try/Catch block (if any) are executed. It serves as "first chance" to take a note of the exception thrown. All exceptions except Stackoverflow and access violation exceptions will be notified to this event. This is subscribed by your Visual Studo debugger, you can verify that by running an sample and throw an exception from your program. You will see following or » Read more

 Jsinh        

These days Redis sparkle in my eyes, for lots of reason but the basic and most important reason is that it is deaam fast. Now we all know this can bring up an never ending debate but I am not going to be part of it because its fast and here I am not referencing it with comparison to other data-stores available. Redis is an open source, advance key-value store. This key thingy can be strings, hashes, lists, sets and / or sorted sets. Quite a list :) Note: This post was tested and written for Redis Version 2.8.3. This may or may not work for other or latest version of Redis Server. I was impressed when I queried who is using Redis and the long list of clients libraries for most of the language available to work with Redis as your Key-Value store. It is made to run on » Read more

 Jsinh