Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Classes/Visual-Basic-.NET/classes-1.vb
Normal file
29
Task/Classes/Visual-Basic-.NET/classes-1.vb
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
Class Foo
|
||||
Private m_Bar As Integer
|
||||
|
||||
Public Sub New()
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub New(ByVal bar As Integer)
|
||||
m_Bar = bar
|
||||
End Sub
|
||||
|
||||
Public Property Bar() As Integer
|
||||
Get
|
||||
Return m_Bar
|
||||
End Get
|
||||
Set(ByVal value As Integer)
|
||||
m_Bar = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Sub DoubleBar()
|
||||
m_Bar *= 2
|
||||
End Sub
|
||||
|
||||
Public Function MultiplyBar(ByVal x As Integer) As Integer
|
||||
Return x * Bar
|
||||
End Function
|
||||
|
||||
End Class
|
||||
22
Task/Classes/Visual-Basic-.NET/classes-2.vb
Normal file
22
Task/Classes/Visual-Basic-.NET/classes-2.vb
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
'Declare and create separately
|
||||
Dim foo1 As Foo
|
||||
foo1 = New Foo
|
||||
|
||||
'Declare and create at the same time
|
||||
Dim foo2 As New Foo
|
||||
|
||||
'... while passing constructor parameters
|
||||
Dim foo3 As New Foo(5)
|
||||
|
||||
'... and them immediately set properties
|
||||
Dim foo4 As New Foo With {.Bar = 10}
|
||||
|
||||
'Calling a method that returns a value
|
||||
Console.WriteLine(foo4.MultiplyBar(20))
|
||||
|
||||
'Calling a method that performs an action
|
||||
foo4.DoubleBar()
|
||||
|
||||
'Reading/writing properties
|
||||
Console.WriteLine(foo4.Bar)
|
||||
foo4.Bar = 1000
|
||||
Loading…
Add table
Add a link
Reference in a new issue