Dim s As String = "Eric Moreau"
s = s.Trim()
s = s.ToUpper()
s = s.Replace("R", "z")
Dim s As String = "Eric Moreau".Trim().ToUpper().Replace("R", "z")
Dim dir As New IO.DirectoryInfo("C:\Windows\System32")
Dim fileList = dir.GetFiles("*.*").
Where(Function(f) f.Name.StartsWith("odbc")).
OrderBy(Function(f) f.FullName)
Dim emp As Employee = New Employee
emp.Name = "Eric Moreau"
emp.Dob = New DateTime(1970, 5, 28)
emp.HireDate = New DateTime(2007, 2, 1)
emp.Salary = 123456
emp.BossName = "Pointy-Haired Boss"
Dim emp2 As Employee = New Employee With {
.Name = "Eric Moreau",
.Dob = New DateTime(1970, 5, 28),
.HireDate = New DateTime(2007, 2, 1),
.Salary = 123456,
.BossName = "Pointy-Haired Boss"
}
Dim emp3 As Employee = New Employee
With emp3
.Name = "Eric Moreau"
.Dob = New DateTime(1970, 5, 28)
.HireDate = New DateTime(2007, 2, 1)
.Salary = 123456
.BossName = "Pointy-Haired Boss"
End With
Public Class Employee
Public Name As String
Public Dob As Date
Public HireDate As Date
Public Salary As Int32
Public BossName As String
Public Overrides Function ToString() As String
Return String.Format(" The employee {0} was hired {1:D} with a salary of {2:c} reports to {3}. He was born on {4:D}", Name, HireDate, Salary, BossName, DOB)
End Function
End Class
Public Interface IEmployeeFluent
Function OfName(ByVal pName As String) As IEmployeeFluent
Function AsOf(ByVal pDate As Date) As IEmployeeFluent
Function BornOn(ByVal pDate As Date) As IEmployeeFluent
Function SetSalary(ByVal pSalary As Int32) As IEmployeeFluent
Function ReportTo(ByVal pName As String) As IEmployeeFluent
End Interface
Public Function OfName(ByVal pName As String) As IEmployeeFluent Implements IEmployeeFluent.OfName
Name = pName
Return Me
End Function
Public Function AsOf(ByVal pDate As Date) As IEmployeeFluent Implements IEmployeeFluent.AsOf
HireDate = pDate
Return Me
End Function
Public Function BornOn(ByVal pDate As Date) As IEmployeeFluent Implements IEmployeeFluent.BornOn
DOB = pDate
Return Me
End Function
Public Function SetSalary(ByVal pSalary As Integer) As IEmployeeFluent Implements IEmployeeFluent.SetSalary
Salary = pSalary
Return Me
End Function
Public Function ReportTo(ByVal pName As String) As IEmployeeFluent Implements IEmployeeFluent.ReportTo
BossName = pName
Return Me
End Function
Dim emp2 As IEmployeeFluent = New Employee()
MessageBox.Show(emp2.
OfName("Eric Moreau").
AsOf(New DateTime(2007, 2, 1)).
BornOn(New DateTime(1970, 5, 28)).
SetSalary(123456).
ReportTo("Pointy-Haired Boss").
ToString())
Public Shared Function Hire() As IEmployeeFluent
Return New Employee
End Function
Dim emp As IEmployeeFluent = Employee.Hire().
OfName("Eric Moreau").
AsOf(New DateTime(2007, 2, 1)).
BornOn(New DateTime(1970, 5, 28)).
SetSalary(123456).
ReportTo("Pointy-Haired Boss")
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (1)
Author
Commented: