编程术语 - 场,成员属性(C#) [英] Programming terms - field, member, properties (C#)

查看:160
本文介绍了编程术语 - 场,成员属性(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到这方面的意义,而且特别是由于语言的障碍,我无法理解他们的用途。
我认为场是可变的(对象吗?)在课堂上,而财产,只是它返回的特定值,并不能包含方法等。通过会员据我所知,声明上的任何对象物体类级别。但这些都是基于注释代码示例只是我的假设,其中一些细致的程序员使用的资产区域等
我会很感激,如果有人可以解释给我。

I was trying to find meaning of this terms but especially due to language barrier I was not able to understand what they are used for. I assume that "field" is variable (object too?) in the class while "property" is just an object that returns specific value and cannot contain methods etc. By "member" I understand any object that is declared on the class level. But these are just my assumptions based on commented code samples where some careful programmers used "property region" etc. I would really appreciate if someone could explain it to me.

推荐答案

在C#中:

字段:这是在类级声明的变量

fields : These are variables declared at the class level.

public class SomeClass
{
    private int someInteger; // This is a field
    public double someDouble; // This is another field
    protected StringBuidler stringBuidler; // Still another field
}



性能:常用作为访问一类的私人领域,他们可以提供获取和设置环绕场操作的一些逻辑方法。

properties : Often used as accessors to a private field of a class, they can provide get and set methods that wrap some logic around the field manipulation.

public class SomeClass
{
    private StringBuilder stringBuilder;

    // Property declaration
    public StringBuilder StringBuilder
    {
        get 
        { 
            if(this.stringBuilder == null)
                this.stringBuilder = new StringBuidler();

            return this.stringBuilder;
        }
        set
        {
            if(this.stringBuilder == null)
                this.stringbuilder = value;
        }
    }
}



成员:包括字段,属性,方法,事件类的

members : Includes fields, properties, methods, events of a class.

这篇关于编程术语 - 场,成员属性(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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