if greater than in C#
Edit: Problem solved, the greater than was the wrong ascii character. Even tho I didn't copy paste it from somewhere. I'll have to check my keyboard language.
Edit: Just to make it clear, effect.Parry is an int? not a decimal. See edit below Edit: I changed the decimalToString. That was an error on my part but I'm still getting the error
I am trying to do a greater than if statement in my code but I am getting an error and I just can't figure what the error is...
Here is the part of the code.
if (effect.Parry != null)
{
txtEffect += " Parry the next " + effect.Parry.ToString() + " attack";
if (effect.Parry > 1)
txtEffect += "s";
if (effect.NumberOfTurn != 0)
{
txtEffect += " over " + effect.NumberOfTurn.ToString();
}
}
And here is the error I get:
Erreur 1 Caractère '-' inattendu
In english it would be: Unexpected character '-'
Can someone explain me what I did wrong? I tried >= and it gives me the same error. If I try without > I don't get an error.
Edit: txtEffect is a string, effect.Parry is an int? (To allow nulls) I tried parsing it into a normal int and I get the same error as above.
Your problem came from defining effect.Parry as an int? and then passing it into a function requiring a decimal? as a parameter. Change one or the other so they match, and you should take care of your problem.
链接地址: http://www.djcxy.com/p/58592.html下一篇: 如果大于C#