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; }
}
精彩评论