Posts

Showing posts from March, 2020

COALESCE in SQL Server

COALESCE in SQL Server COALESCE -  Returns the first non-null value in a list. SELECT COALESCE(NULL, 1, 2 , NULL); Returns 1 as the answer. COALESCE(val1, val2, ...., val_n) If all values are NULL, COALESCE returns NULL.         

Delegates in C#

A delegate is a type-safe function pointer that can reference a method that has the same signature as that of a delegate. In short: Rather than pointing to the actual function, you point to a delegate. Delegates : Used to define callback methods  Implement event handling Declared using "delegate" keyword.  It allows us to pass methods as parameter.  Types of Delegates:  Simple/Single Delegate - When delegate takes reference with single method.  Multicast Delegate - When delegates takes reference with multiple methods. You can make use + and\or (-) sign to add and subtract methods respectively. This creates an invocation list and is called upon the order of addition.  Generic Delegate  Different ways of creating a delegate in C#:  Action - Action takes up to 16 input Parameters and doesn't return a value. Example: delegate int Action (T1 arg1, T2 arg2);  Func Predicate Lambda Anonymous Types. Fun Fact...