VB.Net Tutorial/Class Module/ReadOnly — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 16:40, 26 мая 2010
Demonstrates Const and ReadOnly members
Module Tester
Sub Main()
Dim random As Random = New Random()
Dim circle As MyConstant = New MyConstant(random.Next(1, 20))
Dim radius As String = Convert.ToString(circle.RADIUS)
Console.WriteLine("Radius = " & radius & vbCrLf _
& "Circumference = " + String.Format("{0:N3}", _
circle.RADIUS * 2 * MyConstant.PI))
End Sub
End Module
Class MyConstant
Public Const PI As Double = 3.14159
Public ReadOnly RADIUS As Integer
Public Sub New(ByVal radiusValue As Integer)
RADIUS = radiusValue
End Sub
End Class
Radius = 3 Circumference = 18.850