Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
What are shared (VB.NET)/Static(C#) variables
What are shared (VB.NET)/Static(C#) variables?
✍: Guest
Static/Shared classes are used when a class provides functionality which is not specific to
any instance. In short if you want an object to be shared between multiple instances you
will use a static/Shared class.
Following are features of Static/Shared classes :-
ã They can not be instantiated. By default a object is created on the first method
call to that object.
ã Static/Shared classes can not be inherited.
ã Static/Shared classes can have only static members.
ã Static/Shared classes can have only static constructor.
Public Class ClsShared Shared intCount As Integer Public Function AddCount() As Integer intCount = intCount + 1 Return intCount End Function End Class Public Class FrmSharedClasses Inherits System.Windows.Forms.Form Private Sub CmdInstance1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdInstance1.Click Dim pobjClsShared As New ClsShared() MessageBox.Show(“The count at this moment is” & pobjClsShared.AddCount.ToString()) End Sub Private Sub CmdInstance2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdInstance2.Click Dim pobjClsShared As New ClsShared() MessageBox.Show(“The count at this moment is” & pobjClsShared.AddCount.ToString()) End Sub End Class
2007-10-23, 7405👍, 0💬
Popular Posts:
What is PMP(project management plan)? The project management plan is a document that describes the p...
What is the difference between mysql_fetch_object() and mysql_fetch_array() functions in PHP? mysql_...
An application needs to load a library before it starts to run, how to code? One option is to use a ...
What Is a LABEL Tag/Element? - XHTML 1.0 Tutorials - Understanding Forms and Input Fields A "label" ...
What will be printed as the result of the operation below: #define swap(a,b) a=a+b;b=a-b;a=a-b; void...