Shared (vb.net)/static(c#) variables, DOT NET Programming

Assignment Help:

What are shared (VB.NET)/Static(C#) variables?

Shared/Static classes are used when a class gives functionality which is not specific to any instance. In brief if you want an object to be shared between multiple instances you will use a Shared/Static  class.

The key features of Static/Shared classes are as follows:-

1) They can't be instantiated. By default the object is created on the first method call to that object.

2) The Shared/Static classes can not be inherited.

3) The Shared/Static classes can have only static members.

4) The Shared/Static 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

961_shared in action.png

Figure :-Shared/Static In Action


Related Discussions:- Shared (vb.net)/static(c#) variables

Calculating the sum of digits - c# program, Calculating the Sum of Digits -...

Calculating the Sum of Digits - C# Program Hi, Can any of you, tell me how can i calculate the sum of digits of a given number?

I need to develop a project of call accounting and billing, Project Descrip...

Project Description: General information for the business: Call Accounting and Billing Kind of development: New program from scratch Description of each module: Call Accou

Boxing, What is boxing in .net

What is boxing in .net

Normalization and types of normalization, What is normalization & what are ...

What is normalization & what are the types of normalization? Normalization is a set of rules that have been established to aid in the design of tables that are meant to be conn

Explain some built-in functions of vbscript, Problem: (a) Explain the ...

Problem: (a) Explain the difference between these two lines of ASP codes: (b) The VBScript language includes some built-in functions which are often used in ASP co

System simulation, System Simulation - repost 2 Project Description: ...

System Simulation - repost 2 Project Description: A. Prepare random numbers of the form: Case 1: Uniformly distributed random numbers (RNs) [range: 0.0-1.0] Case 2: Exp

What is microsoft intermediate language, What is Microsoft Intermediate Lan...

What is Microsoft Intermediate Language (MSIL)? The .NET Framework is shipped with compilers of all .NET programming languages to develop programs. There are separate compilers

Need report generation in sql and .net, Need Report Generation in SQL / .NE...

Need Report Generation in SQL / .NET Project Description: Prepare a report generation web page by pulling information from an SQL Database. Filter parameters per report :

Different types of jit, JIT compiler is the part of the runtime execution e...

JIT compiler is the part of the runtime execution environment. In Microsoft .NET there are three types  of JIT compilers are available: 1) Pre-JIT :- The Pre-JIT compiles the co

A crm based on .net and oracle as backend, A CRM based on .net and Oracle a...

A CRM based on .net and Oracle as backend with import data, Transaction Reporting and management Capabilities Project Description: 1. Introduction ADA recovery Branch gets

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd