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.
why are some .NET methods written wrapped in brackets? [duplicate]
-
09-10-2022 - |
문제
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
해결책
다른 팁
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.
제휴하지 않습니다 StackOverflow