Posted by: Sourav | August 4, 2016

Static is Shared in VB


Public Class circlearea
Shared PI As Double

Dim radious As Double
Sub New(ByVal radious As Double)
Me.radious = radious
End Sub
‘this will run even before the creation of an instance of the class
Shared Sub New()
PI = 3.14
End Sub
Function printarea() As Double
Return PI * radious * radious

End Function

End Class

Module Module1

Sub Main()

Dim ca As circlearea = New circlearea(5)
Dim area As Double = ca.printarea
Console.WriteLine(“The area is {0}”, area)
Console.ReadLine()

End Sub

End Module

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: