Friday, May 23, 2014

Strong Reference Vs WeakReference.

If an object is reachable by application code it can not collected by GC this is called Strong Reference.

A weak reference permits the garbage collector to collect the object while still allowing the application to access the object. Weak reference are useful for objects  that use a lot of memory but can be re created easily if they are reclaimed by garbage collector. WeakReference is a data type in .Net.



Friday, May 16, 2014

Unique Index


A Unique index ensures that no one can enter duplicate values for that particular column(s).If you you insert 10 rows with the help of single queries which contain 5 duplicate values it reject all rows including non duplicate for this you have to use IGNORE_DUP_KEY caluse. it will insert non duplicate rows and reject duplicates rows. A unique index can not be created if column(s) already contain duplicate values. You can create unique index on composite column.Even null is considered as a value for unique index you can not insert multiple null values.

Friday, May 9, 2014

Threading

.Net support parallel execution of code through multithreading.  A thread is a lightweight process.

Some methods used in Threading

Join  :-  If one thread is running and you want to start a new thread after ending the first one. You can call join methods for that.

t2.join();

Sleep :- If you want to suspend the thread for some time you can use Sleep method.

Abort  :-  You can abort the thread forcefully in the middle by using abort method.

Friday, May 2, 2014

When you have used Interface

This is most frequent question of interviewer ‘tell me the real scenario where you have used interface’. I would like to explain my experience where I have used Interface.

I have created a class named ‘CCommon’. In which  I have defined a method named Load(..).  The functionality of Load was to set the forms properties like.  WindowState,MaximizeBox, BackColor etc. It is required to set these properties for each form. I need to call this method for each ‘n’ every form in the project.

So I have required such object in Load function which can be used for every form. In this order I have created an Interface ICommon and implement every form from this Interface.
And defined Load method as

///
       ///
       ///
       ///
       internal void Load(ICommon objICommon)
       {                        
           objICommon.Text_Form =  ApplicationName;
           objICommon.MaximizeBox_Form = false;
          // objICommon.MinimizeBox_Form = false;
           objICommon.MinimumSize_Form = new Size(objICommon.Width_Form, objICommon.Height_Form);
           objICommon.MaximumSize_Form = new Size(objICommon.Width_Form, objICommon.Height_Form);
           objICommon.StartPos_Form = FormStartPosition.CenterScreen;                     
       }


Followers

Link