Home > Net >  What do these Square Brackets C# syntax mean infront of Function Parameters? It looks like attribute
What do these Square Brackets C# syntax mean infront of Function Parameters? It looks like attribute

Time:06-28

I'm trying to work out what this code does. It's part of the .NET framework and MS Azure; I have a C background, but (obviously) C# is a different animal.

Having spent much time googling "square bracket use in c#" I believe that the first use of the square brackets is for an attribute. 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 )
{
    ...
}

CodePudding user response:

Those are Attributes. There is an entire article about them in C#

Aside from many "built-in" (based on nuget packages), you can also freely define your own custom attributes.

  • Related