VB.Net/2D/Public

Материал из VB Эксперт
Версия от 12:42, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Public Member Variable

Imports System
Public Class MainClass
    Shared Sub Main(ByVal args As String())
      Dim d1 As New Dog( )
      d1.weight = 5
      Dim d2 As Dog = d1
 
      Console.WriteLine("Milo: {0}, d2: {1}", d1.weight, d2.weight)
      d2.weight = 7
      Console.WriteLine("Milo: {0}, d2: {1}", d1.weight, d2.weight)
    End Sub
End Class
Public Class Dog
    Public weight As Integer
End Class


Use Public Member variables

Imports System.IO
Module Module1

    Sub Main()
        Dim Drama As New Movie("Name 1", "Wednesday", "8:00PM")
        Dim Medical As New Movie("Name 2", "Thursday", "9:00PM")
        Dim Comedy As New Movie("Name 3", "Thursday", "7:00PM")
        Console.WriteLine("Show: " & Drama.Name)
        Console.WriteLine("Day: " & Drama.Day)
        Console.WriteLine("Time: " & Drama.Time)
    End Sub
End Module
    Class Movie
        Public Name As String
        Public Day As String
        Public Time As String
        Sub New(ByVal ShowName As String, ByVal DayOfWeek As String, ByVal ShowTime As String)
            Console.WriteLine("Name: " & ShowName & " Day " & DayOfWeek & " Time " & ShowTime)
            Name = ShowName
            Day = DayOfWeek
            Time = ShowTime
        End Sub
    End Class