简体   繁体   English

方括号在C#中的作用是什么

[英]What is the role of square bracket in C#

I don't understand the square bracket role 我不明白方括号的作用

System.ServiceProcess.ServiceBase[] ServicesToRun;

Can anyone tell me what is the role of square bracket in above statement? 谁能告诉我以上声明中方括号的作用是什么?

此语法特定于C#,而不特定于.NET,并指示数组的声明。

This says that the variable ServicesToRun is an array of ServiceBase instances. 这表示变量ServicesToRunServiceBase实例的数组。 See here for more informations about arrays: 请参阅此处以获取有关数组的更多信息:

http://msdn.microsoft.com/en-us/library/9b9dty7d.aspx http://msdn.microsoft.com/zh-CN/library/9b9dty7d.aspx

From [] Operator (C# Reference) : 来自[]运算符(C#参考)

Square brackets ( [] ) are used for arrays, indexers, and attributes. 方括号( [] )用于数组,索引器和属性。 They can also be used with pointers. 它们也可以与指针一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM