C#只是一些代码问题............ [英] C# Just a little code problem............

查看:88
本文介绍了C#只是一些代码问题............的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码

This is my code

if ((You.Location = new Point(-1,-1)) >= ((You.Location = new Point(300,-1))
      {
      }



我做了一个大嘘声,嘘,有人可以帮我解决这个问题吗?

这也是我的错误



And I made a big boo boo can anyone plz help me fix this up

this is my error also

Error	1	Cannot implicitly convert type ''System.Drawing.Point'' to ''bool''	C:\Users\Kyle\documents\visual studio 2010\Projects\Game 1\Game 1\Form2.cs	194	18	Game 1<br />

推荐答案

哈,哈,哈,好吧,你真的不能,为什么你认为可以呢?

顺便说一句,您无法得到此编译错误,首先它会抱怨括号不平衡,然后在您进行修复时,编译器会抱怨比较运算符.实际上,向右和向左运算符分配给Location属性,该属性的类型为Point.如何比较点(作为2D对象)?此类操作未定义,因为...有人解释过您在2D上没有订购吗?当然,除非您以自己的方式对其进行了定义.

而且,双重赋值(实际上是相等的意思是"=="吗?)好吧,如果是赋值,那是没有意义的,因为对同一对象的相同属性的第二个赋值会击败第一个赋值的效果. ...

这一切都不好笑...

—SA
Ha, ha, ha, well, you cannot really, why would you think you can?

By the way, you could not get this compilation error, first it would complain about unbalanced brackets, and when you fix then, compiler would complain about comparison operator. Indeed, right and left operators are assignment to the Location property, which is of type Point. How can you compare points (as 2D objects)? Such operation is not defined, because... Did anyone explained you that on 2D there is no ordering? Unless you defined it somehow in your own type, of course.

Moreover, double assignment (did you mean "==", in fact, equality?), well, if it is assignment, it makes no sense, because second assignment of the same property of the same object defeats the effect of the first one...

All this is not even funny...

—SA


不太确定您要在这里做什么.因此无法给出确切答案.
但是,不能比较两个Location 对象.

您需要比较此Location 对象的x和y坐标.
Not quite sure what you are trying to do here. So cannot give an exact answer.
However, you cannot compare two Location objects.

You need to compare the x and y co-ordinates of this Location object.


这篇关于C#只是一些代码问题............的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆