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

Comparison of asp.net session with classic asp session, What are ASP.NET se...

What are ASP.NET session and compare it with classic ASP session The ASP.NET session caches per user session state. It basically uses "HttpSessionState" class. The limitatio

Function points, What are function points? The FPA is breaking huge sys...

What are function points? The FPA is breaking huge systems into smaller pieces and analyzing them. The Software application is a combination of set of elementary processes. The

I need kinect fitting room - smart fitting mirror, I need Kinect Fitting Ro...

I need Kinect Fitting Room - Smart Fitting Mirror I'm presently looking for someone able to create software exactly like this fitnect (Kinect Fitting Room). Software can work

Explain ado.net in brief, Explain ADO.NET in brief. ADO.NET is a very s...

Explain ADO.NET in brief. ADO.NET is a very significant feature of .NET Framework, which is used to work with data that is stored in structured data sources, like databases and

Perform arithmetic operations - c# program, Perform Arithmetic Operations -...

Perform Arithmetic Operations - c# Program Hello, i didn't find the correct way of using arithmetic operations in c#. I am beginner for this language. Please suggest me some e

Finding average of array elements - c# program, Finding Average of Array El...

Finding Average of Array Elements - C# Program I need assignment help for Finding Average of Array Elements in C#. Can anybody send me there ideas?

Describe the rules creating a well-formed xml document, Describe the rules ...

Describe the rules and regulations that must be followed whereas creating a well-formed XML document. The following are the rules and regulations that are essential to follow w

I need .net and c# expert help for advance project, I need .net expert help...

I need .net expert help for Advance Project First let me start by saying that I have been writing code for almost 25 years. Therefore I am only looking for someone to aid advanc

Ado.net architecture, Can you give an overview of ADO.NET architecture? ...

Can you give an overview of ADO.NET architecture? The most important part  in the ADO.NET architecture is the "Data Provider". The  Data Provider provides access to the datasou

A simple desktop software, Project Description: I am seeking software th...

Project Description: I am seeking software that can do the subsequent: 1. Check position for a URL in Google, Bing, Yahoo. 2. Check position for a Youtube video in Youtube

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