> =操作数不能应用于Bool和Float类型

时间:2014-01-18 20:33:38

标签: c# boolean operand

我有这句长篇大论。它给了我错误

>= Operand cannot be applied to types Bool and Float

if (tl.State == TouchLocationState.Pressed && 
    (tl.Position.X >= harePlayer.Position.X >= tl.Position.X && 
     tl.Position.Y >= harePlayer.Position.Y &&
     harePlayer.Position.X <= (harePlayer.Position.X + 52) &&
     tl.Position.Y <= (harePlayer.Position.Y + 50)))

有人能告诉我修复的是什么吗?谢谢。 :)

1 个答案:

答案 0 :(得分:8)

tl.Position.X >= harePlayer.Position.X >= tl.Position.X c#条件不正确。您必须编写两个单独的条件并使用&&合并它们:

tl.Position.X >= harePlayer.Position.X && harePlayer.Position.X >= tl.Position.X