这是什么意思 ?公共名称{;组;} [英] What does this mean ? public Name {get; set;}

查看:108
本文介绍了这是什么意思 ?公共名称{;组;}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到这个安静经常在C#文档。 ?但是它有什么作用

 公共类汽车
{
公共名称{;组; }
}


解决方案

这是简写:

 私人字符串_name; 

公共字符串名称
{
{返回_name; }
集合{_name =价值; }
}



编译器生成的成员变量。这就是所谓的自动财产


I see this quiet often in C# documentation. But what does it do?

public class Car
{
   public Name { get; set; }
}

解决方案

It is shorthand for:

private string _name;

public string Name
{
    get { return _name; }
    set { _name = value; }
}

The compiler generates the member variable. This is called an automatic property.

这篇关于这是什么意思 ?公共名称{;组;}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆