Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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; 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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel


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

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading