26.02.2015 Views

DOT NET Interview Questions - DotNetSpider

DOT NET Interview Questions - DotNetSpider

DOT NET Interview Questions - DotNetSpider

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Following are features of Static/Shared classes :-<br />

√<br />

√<br />

√<br />

√<br />

They can not be instantiated.By default a object is created on the first method<br />

call to that object.<br />

Static/Shared classes can not be inherited.<br />

Static/Shared classes can have only static members.<br />

Static/Shared classes can have only static constructor.<br />

Note :- In CD there is a folder “WindowsShared” which has a sample code for shared<br />

variables.Below is a snippet.It has a “AddCount” function which increments a static<br />

“intCount” variable.In form there are two buttons which creates a new object and displays<br />

the count of the static variable.Even though the object is created and destroyed , the variable<br />

values does not change.It retains its old value.<br />

Public Class ClsShared<br />

Shared intCount As Integer<br />

Public Function AddCount() As Integer<br />

intCount = intCount + 1<br />

Return intCount<br />

End Function<br />

End Class<br />

Public Class FrmSharedClasses<br />

Inherits System.Windows.Forms.Form<br />

Private Sub CmdInstance1_Click(ByVal sender As System.Object, ByVal<br />

e As System.EventArgs) Handles CmdInstance1.Click<br />

Dim pobjClsShared As New ClsShared()<br />

MessageBox.Show(“The count at this moment is” &<br />

pobjClsShared.AddCount.ToString())<br />

End Sub<br />

Private Sub CmdInstance2_Click(ByVal sender As System.Object, ByVal<br />

e As System.EventArgs) Handles CmdInstance2.Click<br />

Dim pobjClsShared As New ClsShared()<br />

MessageBox.Show(“The count at this moment is” &<br />

pobjClsShared.AddCount.ToString())<br />

End Sub<br />

End Class<br />

112<br />

* Can you explain logic of binary sort ?

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!