VB.Net/2D/Public — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 12:42, 26 мая 2010

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