Domanda

I am new to programming and this might be a very elementary question, but I was wondering what items placed inside [brackets], such as [TestMethod] and [CodedUITest] are called and what their role is in .NET. Why is it that these methods are written in this manner?

Thanks

È stato utile?

Soluzione

Those are called Attributes. They give your code metadata the IDE can use to do things like know which methods are unit tests, how to serialize a class, or what to show first in intellisense prompts.

Altri suggerimenti

They are Attributes

Attributes can be placed on most any declaration, though a 
specific attribute might restrict the types of declarations on which it is valid.
In C#, you specify an attribute by placing the name of the attribute, enclosed in square brackets ([]), above 
the declaration of the entity to which it applies. In Visual Basic, an attribute
is enclosed in angle brackets (< >). It must appear immediately before the element to 

which it is applied, on the same line.

Attributes

Introduction to Attributes

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top