简体   繁体   English

这些方括号 C# 语法在函数参数前面是什么意思? 看起来像属性

[英]What do these Square Brackets C# syntax mean infront of Function Parameters? It looks like attributes

I'm trying to work out what this code does.我正在尝试弄清楚这段代码的作用。 It's part of the .NET framework and MS Azure;它是 .NET 框架和 MS Azure 的一部分; I have a C++ background, but (obviously) C# is a different animal.我有 C++ 背景,但(显然)C# 是另一种动物。

Having spent much time googling "square bracket use in c#" I believe that the first use of the square brackets is for an attribute.花了很多时间在谷歌上搜索“c#中的方括号使用”我相信方括号的第一次使用是用于属性。 But I've found nothing that says there can be attributes as part of a parameter within a function call, and can find no information on the subject..但是我没有发现任何东西可以说在函数调用中可以将属性作为参数的一部分,并且找不到关于该主题的信息..

I'm pretty sure they're not indexers, what does the syntax in the square brackets represent?我很确定它们不是索引器,方括号中的语法代表什么?


[FunctionName("orderProcessor")]
public static void Run(
   [ServiceBusTrigger("ordersTopic)] string myQueueItem,
   [Blob("orders/{id}",FileAccess.Write] Stream order,
   ILogger log )
{
    ...
}

Those are Attributes .这些是Attributes There is an entire article about them in C#在 C# 中有一篇关于它们的整篇文章

Aside from many "built-in" (based on nuget packages), you can also freely define your own custom attributes .除了许多“内置”(基于 nuget 包)之外,您还可以自由定义自己的自定义属性

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

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