Reputation: 97
I have one varibale endtime which I have declared like this:
Dim endtime As TimeSpan.
I am getting some time to this variable. example(10:00:01). I want to check my endtime is greater than or equal to 12,clock so I try to given code like this:
if(endtime>=12)
But it is showing error like this:
Overload resolution failed because no accessible > can be called with this argument and value type integer cannot be converted to
system.timespan
.
How I can compare my endtime value to other time? If any one know please help me.
Upvotes: 1
Views: 4589
Reputation: 711
Try this piece of coding
endtime>= #12:00:00 PM#
Or browse to the link below
Upvotes: 1
Reputation: 216348
You should simply create another TimeSpan variable with the desired value and then you could compare the two variables
Dim t2 = new TimeSpan(10,0,1)
Dim t1 = new TimeSpan(12,0,0)
if t1 > t2 then
Console.WriteLine("T2 greater than T1")
Else
Console.WriteLine("T1 greater than T2")
End If
Upvotes: 2