문제

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

도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top