Sunday, April 5, 2015

Difference between Session and Query String

Querystring Session
Querystring is client side state management technique. Session is server side state management technique.
Querystring data is page specific i.e. can be accessed in that page only. Session data can be accessed throughout the session.
Querystring data is visible to user and can be seen in browser url. Session data is not visible to user.
Data is not secured and can be altered hence insensitive data is stored in querystring. Data is secured hence sensitive data such as user information is stored.
Querystring has constraint of Maxlength. Session does not have such constraint.
Querystring passed through url like
www.abc.com?myparam=12.
Session created in application like
Session["mysession"] = somevalue.
Querystring fetched on page like
string myvalue = Request.QueryString["myparam"].
Session retrived in application like
string myvalue = Session["mysession"].

Difference between Get Method and Post Method

Get Post
Data retrieved using this is cached by the browser Data retrieved using this is not cached by the browser
Data is passed through URL. Data is passed through body.
Data sent using this is visible in URL. Data sent using this is not visible in URL.
Used to send normal data. Used to send secured and important data.
There is limit over amount of data that can be sent using Get depends on browsers. There is no limit over amount of data that can be sent using Post.
This is default method for many browsers. This is not default method and have to be explicitly defined.
Get method can carry only text data Post method can carry text as well as binary data.
Get method is faster as compared to Post Post method is slower as compared to Get

Thursday, February 5, 2015

Difference between Interface and Abstract Class

Interface Abstract Class
Interface is nothing but contract of the system which can be implemented on classes. Abstract class is special kind of class that can not be instantiated but can be inherited.
A class may inherit several interfaces. A class may inherit only one abstract class.
An interface cannot provide any code, just the signature. An abstract class can provide signature as well as code to be overridden in the child classes.
Members of interface does not have any access modifier. Members of abstract class have an access modifier.
An interface can not contain fields, constructor, destructor. An abstract class can contain fields, constructor, destructor.
A class implementing an interface has to implement all the methods of the interface A class implementing an abstract class does not need to implement all the methods of the abstract class
If we add a new method to an Interface then we have to track down all the implementations of the interface and define implementation for the new method. If we add a new method to an abstract class then we have the option of providing default implementation and therefore all the existing code might work properly.
Reference can be created, it depends on child class object's memory. Reference can not be created.

Difference between Value Type and Reference Type

Value Type Reference Type
Value type they are stored on stack Reference type they are stored on heap
When passed as value type new copy is created and passed so changes to variable does not get reflected back When passed as Reference type then reference of that variable is passed so changes to variable does get reflected back
Value type store real data Reference type store reference to the data.
Value types are faster in access Reference types are slower in access.
Value type consists of primitive data types, structures, enumerations. Reference type consists of class, array, interface, delegates
Value types derive from System.ValueType Reference types derive from System.Object
Value types can not contain the value null. Reference types can contain the value null.

Sunday, February 1, 2015

Difference between Truncate and Delete Command in SQL

TRUNCATEDELETE
TRUNCATE is a DDL commandDELETE is a DML command
TRUNCATE is executed using a table lock and whole table is locked for remove all records.DELETE is executed using a row lock, each row in the table is locked for deletion.
We cannot use Where clause with TRUNCATE.We can use where clause with DELETE to filter & delete specific records.
Minimal logging in transaction log, so it is performance wise faster.It maintain the log, so it slower than TRUNCATE.
TRUNCATE TABLE removes the data by deallocating the data pages used to store the table data and records only the page deallocations in the transaction log.The DELETE statement removes rows one at a time and records an entry in the transaction log for each deleted row
Identify column is reset to its seed value if table contains any identity column.Identity of column keep DELETE retain the identity
To use Truncate on a table you need at least ALTER permission on the table.To use Delete you need DELETE permission on the table.
Truncate uses the less transaction space than Delete statement.Delete uses the more transaction space than Truncate statement.
Truncate cannot be used with indexed viewsDelete can be used with indexed views
TRUNCATE TABLE can’t activate a trigger because the operation does not log individual row deletions. When we run truncate command to remove all rows of table then it actually doesn’t removes any row, rather it deallocates the data pages. In case of Truncate triggers will not be fired because no modification takes place, we have just deallocated the data pages not deleted any row from table.Delete activates a trigger because the operation are logged individually. When we execute Delete command, DELETE trigger will be initiated if present. Delete is a DML command and it deletes the data on row-by-row basis from a table. Which means delete is modifying the data by deleting it from the table. Triggers are fired when a DML statement executed on a table, so trigger will be fired in case of Delete command execution.

Friday, January 30, 2015

Difference between C++ and C#

C++ and C# both are object oriented languages. Lets check out the main difference between them:-
C++ C#
In C++ programmer have to free the memory. In C# has Garbage collector which frees the memory
In C++ multiple inheritance is supported In C# multiple inheritance is not supported
In C++ we have pointers which manipulate memory illegally In C# we access memory legally.
In C++ access modifiers are public, private and protected. In C# access modifiers are public, private, protected, Internal and protected internal.
C++ uses semicolon at the end of class definition. C# does not use semicolon at the end of class definition.
C++ supports macros. C# does not support macros.
C++ is language not type-safe. C# is language type-safe.
C++ code usually compiles to assembly language C# code usually compiles to intermediate language.

Wednesday, January 28, 2015

Difference between Stored Procedures and Functions


Stored Procedures Functions
Stored procedures are stored in parsed and compiled format in the database. Functions are compiled and executed at run time.
Stored procedures can not be called in SQL statement like Select. Functions can be called in SQL statement like Select.
Stored procedures are usually used for Business logic. Functions are normally used for computations.
Stored procedures can contain DML statements. Functions can not contain DML statements.
Exception can be called in stored procedure by TRY-CATCH Block. Exception can not be used in Function
Stored Procedure may or may not return a value. Function will always return a value & it can be only single value.
Transaction management is possible in Procedure Transaction management Is not possible in Function
A Function can be called inside a stored procedure A stored procedure can not be called inside a function.

Popular Posts