对于人们来说,这可能是一个简单的问题,但我不明白为什么会这样.这是我的代码第1条:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace GameCore { public class PlayerCharacter { public void Hit(int damage) { Health -= damage; if (Health <= 0) { IsDead = true; } } public int Health { get; private set; } = 100; public bool IsDead{ get; private set; } } }
现在Visual Studio在赋值符号(=)上给出了无效的令牌错误(根据标题),我看不出原因.有谁可以解释这个吗?
我要做的是将生命的int设置为100,每次角色受到伤害时,生命值会降低.谢谢大家.
我正在使用Visual Studio 2013 v12.0.40629.00更新5
解决方法
原文地址:https://www.jb51.cc/csharp/244328.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。