VB.NET 物件初始化(Intializer)

1 篇文章 / 0 new
author
VB.NET 物件初始化(Intializer)
Imports mod06.Domain.IT
Module TestSalesObjectIntializer
    Public Sub Main()
        '定義區域變數 透過屬性初始化物件
        Dim sales As New Sales() With {.Id = "0001", .Name = "eric", .BirthDate = New DateTime(2000, 1, 1), .Sex = "男性", .Qa = 50000}
        sales.Salary = 20000
        '建構建構子
        Dim sales2 As New Sales("0002", "linda", New DateTime(2000, 12, 31), "女性", 60000)
 
        Dim sales3 As New Sales()
        sales3.Id = "0003"
    End Sub
End Module

from
http://www.dotblogs.com.tw/timothy/archive/
關鍵字: 
Free Web Hosting