0
我不擅長VB,而且我有一些修復某些問題的嚴重問題。 對於學校要我做任務,我有一些測試,所有具有運行真如何獲取函數中的對象的屬性,當它不在參數中
Console.WriteLine(placeToStay1.Overlapswith(placeToStay2) = False) 'True
Console.WriteLine(placeToStay1.Overlapswith(placeToStay3) = False) 'True
Console.WriteLine(placeToStay1.Overlapswith(placeToStay4) = True) 'True
Console.WriteLine(placeToStay1.Overlapswith(placeToStay5) = True) 'True
Console.WriteLine(placeToStay1.Overlapswith(placeToStay6) = False) 'True
Console.WriteLine(placeToStay1.Overlapswith(placeToStay7) = False) 'True
與性能的placeToStay的例子:
Dim placeToStay1 As New placeToStay
placeToStay1.Room = 123 'String
placeToStay1.From = #10/23/2013# 'Date
placeToStay1.Till = #10/28/2013# 'Date
這是我在我的班級中:
Public Class placeToStay
Public Property Room As String
Public Property From As Date
Public Property Till As Date
Dim _tillDate As Date = Till
Public Function OverlapsWith(date2 As placeToStay) As Boolean
Dim TheBool As Boolean
If _tillDate > date2.From Then
TheBool = True
Else
TheBool = False
End If
Console.WriteLine(_tillDate)
Return TheBool
End Function
End Class
正如您可能已經猜到的那樣,根本不會返回true。 如果沒有在參數中給出,我如何從placeToStay1獲得Till屬性?
的testcode必須保持不變(Console.WriteLine命令行) 歡迎任何幫助:)