Invalid token '=' in class, struct, or interface member declaration c#

前端 未结 3 943
时光说笑
时光说笑 2020-12-11 18:49

this may be a simple question for people, but I can\'t see why this is occurring. here is my code 1st:

using System;
using System.Collections.Generic;
using         


        
3条回答
  •  臣服心动
    2020-12-11 19:36

    the answer was:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace GameCore
    {
        public class PlayerCharacter 
        {
    
            public int Health { get; private set; }
    
            public PlayerCharacter()
            {
                this.Health = 100;
            }
    
    
            public void Hit(int damage)
            {
                Health -= damage;
    
    
                if (Health <= 0)
                {
                    IsDead = true;
                }
            }
    
    
    
    
            public bool IsDead{ get; private set; }
    
        }
    }
    

    making the constructor a function with () and not as PLayerCharacter{ etc.

    thanks to all, back into my hole I go.

提交回复
热议问题