开发者

define get or set in c# 2 [duplicate]

开发者 https://www.devze.com 2023-01-12 01:57 出处:网络
This question already has answers here: Closed 12 years ago. friends i have problem with using get or set in class in c#
This question already has answers here: Closed 12 years ago.

friends i have problem with using get or set in class in c# when i use get or set in gives error(invalid token { in class) pls, see below code,i have this problem in it

namespace ConsoleApplication2
{
    class Program
    {
      class Car
      {
        private int _speed;  
        public int Speed;
        {
          get
          {
           return _speed
        开发者_如何学Go  }
       }
    }
}


You have a semi colon after Speed. It should be:

public int Speed
{ 
     get { return _speed; } 
}
0

精彩评论

暂无评论...
验证码 换一张
取 消