是什么属性和方法之间的区别? [英] What is the difference between a property and a method?

查看:113
本文介绍了是什么属性和方法之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题说明了一切,什么是属性和方法之间的区别?

Title says it all, what is the difference between a property and a method?

推荐答案

该文档会说,这一切为好。

The docs will say it all as well.

一个属性基本上是一个setter和放大器语法糖;吸气。这是相当多了。

A property is basically syntax sugar for a setter & getter. That's pretty much it.

在幕后它只是检索和设置支持字段的值。如果你明确地创建一个支持字段,你可以直接在 GET 设置来该领域更容易定制。但最终它只是一个二传手&安培;吸气。

Behind the scenes it will just retrieve and set the value of the backing field. If you explicitly create a backing field, you can direct the get and set to that field for easier customization. But in the end it's just a setter & getter.

属性结果
方法

这篇关于是什么属性和方法之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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