Posts

SQL Server Interview Question - What is trigger and different types of Triggers?

Trigger is a SQL server code, which execute when a kind of action on a table   occurs like insert, update and delete. It is a database object which is bound to   a table and execute automatically. Triggers are basically of two type’s namely " After Triggers "   and " Instead of Triggers ". 1.After Triggers:-   this trigger occurs after when an insert,   update and delete operation has been performed on a table. “After Triggers” are further divided into three types AFTER INSERT Trigger. AFTER UPDATE Trigger. AFTER DELETE Trigger. Let us consider that we have the following two tables. Create “Customer” table with the following field as you see in the below   table. Cust_ID Cust_Code Cust_Name   Cust_Salary 1 A-31 Moosa 4500 2 A-09 Feroz 5000 3 A-16 Wasim 4000 Create “Customer_Audit” table with the following field as you see in the   below table. Cust_ID   Cust_Name Operation_Performed Date_Time...

Difference between ref and out parameters

Ref and out parameters are used to pass an argument within a method. In this article, you will learn the differences between these two parameters. Ref The ref keyword is used to pass an argument as a reference. This means that when value of that parameter is changed in the method, it gets reflected in the calling method. An argument that is passed using a ref keyword must be initialized in the calling method before it is passed to the called method. Out The out keyword is also used to pass an argument like ref keyword, but the argument can be passed without assigning any value to it. An argument that is passed using an out keyword must be initialized in the called method before it returns back to calling method. Program with ref and out keyword public class Example { public static void Main () //calling method { int val1 = 0 ; //must be initialized int val2 ; //optional Example1 ( ref val1 ); Console . WriteLine ( val1 ); // val1=1   ...

Abstract Class In C#

Abstract class is a special type of class which cannot be instantiated and acts as a base class for other classes. Abstract class members marked as abstract must be implemented by derived classes. The purpose of an abstract class is to provide basic or default functionality as well as common functionality that multiple derived classes can share and override. For example , a class library may define an abstract class that is used as a parameter to many of its functions, and require programmers using that library to provide their own implementation of the class by creating a derived class. In C#, System.IO.FileStream is an implementation of the System.IO.Stream abstract class. abstract class ShapesClass { abstract public int Area (); } class Square : ShapesClass { int side = 0 ;   public Square ( int n ) { side = n ; } // Override Area method public override int Area () { return side * side ; } }   class Rectangle : ShapesC...