开发者

define get or set in c# 2 [duplicate]

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜