Saturday, 17 December 2016

Typeof() vs GetType()


 GetType():
====================
if you want to obtain the type from an instance of your class,you can use GetType().

GetType() returns run time type of the instance.

TypeOf():
===============
if you don't have an instance,but you know the type name,you would use typeof().

TypeOf() gives the compile time of class.

Note :
=====
Operator TypeOf(ClassName) is used to obtain the System.Type object for a Type at compile time.

MyObject.GetType() is used to obtain the exact run time type of object.This method uses reflection.

Finalize vs Dispose in C#

Finalize() is called by Garbage Collector to free unmanaged resources.The garbage collector calls this method at some point after there are no longer valid references to the object.

some resources like windows handles,database connections which cannot be collected by the
garbage collector.Therefore the programmer needs to call Dispose() method of IDisposable interface.

Dispose() of IDisposable interface is called by the programmer to explicitly release resources when they are no longer being used.Dispose() can be called even if other references to the object are alive.

Arguments vs Parameters in C#

Parameters :
==================
A parameter is a variable in
a method definition.

ex :
public void MyMethod(string my param)
{
// your coding
}


Arguments :
================
when a method is called,the arguments
are the data you pass into the method's
parameteres.

ex :
string myarg1="This is my argument";
myclass.MyMethod(myarg1);

Monday, 18 January 2016

Bundling and Minification in asp.net MVC

Bundling and Minification techniques reduce the number of request to the server and size of requested CSS and JavaScript library,which improve page loading time.

Bundling reduces the number of individual HTTP request to server by combining multiple CSS files and JavaScript files into single CSS file and JavaScript file.

Minification reduces the file download size of CSS and JavaScript files by removing white space,comments and other unnecessary characters.

Advantage of Bundling :
=====================
Bundling and Minification primarily improve the first page request load time.
Once a web page has been requested,the browser caches the assets(JavaScript ,CSS and images).
So bundling and Minification won't provide any performance boost when requesting the same
page,or pages on the same site requesting the same assets.

Note :
In debug mode bundling is switched off by default.To enable bundling in debug-mode

BundleTable.EnableOptimizations=true;

Sunday, 17 January 2016

NoLock & NoWait in sql server

NOWAIT will return error if the original table has (transaction) locked on it.

NOLOCK will read the data irrespective of the (transaction) lock on it.