VB.Net/Language Basics/With — различия между версиями

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

Версия 16:40, 26 мая 2010

With command

Imports System.IO
Module Module1
    Sub Main()
        Dim t As Today = New Today
        With t
            Console.WriteLine("Today: " & .TodayDate)
            Console.WriteLine("Day: " & .Day)
            Console.WriteLine("Month: " & .Month)
            Console.WriteLine("Year: " & .Year)
            Console.WriteLine("Day of week: " & .NumericDayOfWeek)
            Console.WriteLine("Day of week: " & .StringDayOfWeek)
        End With
    End Sub
End Module
    Class Today
        Public Shared TodayDate As DateTime = Now()
        Public Shared Day As Integer = Now.Day()
        Public Shared Month As Integer = Now.Month()
        Public Shared Year As Integer = Now.Year()
        Public Shared NumericDayOfWeek As Integer = Now.DayOfWeek()
        Public Shared StringDayOfWeek As String = Now.DayOfWeek.ToString()
    End Class