阵列和数组属性之间的区别? [英] difference between array and properties of an array?

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

问题描述

区别



string [] order = new order();





public string [] order {get; set;}

difference between

string[] order=new order();

and
public string[] order{get;set;}

推荐答案

string[] order=new order();

创建一个引用字符串数组的变量。然后它尝试为它分配一个名为order的类的新实例 - 这意味着编译错误,或者order类是从字符串数组派生的。



Creates a variable which refers to an array of strings. It then tries to assign a new instance of a class called "order" to it - which either means a compilation error, or that the "order" class is derived from an array of strings.

public string[] order{get;set;}

声明一个可以接受并返回数组的自动属性字符串。它不会创建任何实例,并且会重新运行null值,除非为其分配实例。

实际上,它创建了一个引用字符串数组的变量,以及两个方法(一个getter)获取和设置创建变量的值的setter) - 这是访问变量的唯一方法。

Declares an automatic property that can accept and return an array of strings. It does not create any instances, and will rerun a null value unless an instance is assigned to it.
In reality, it creates a variable which refers to an array of strings, and two methods (a getter and a setter) which get and set the value of the created variable - and which are the only way to access the variable.


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

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