I am reading this article on provider patren. Kindly guide me what do this statement:
[ConfigurationProperty("providers")]
Actually I want to learn what is [] ? I also saw such a line on web methods with []. What are [] ? what is there use ? I am even not aware to search what I should name it ? plz guide and help me.
Thanks
[Foo(bla)]is the syntax for an attribute – additional metadata about some type or member (or even the assembly itself; or indeed parameters). You can write your own attributes, for example that one is something like:the name
Attributeis inferred, so only[ConfigurationProperty]is needed. The string"providers"is used as a constructor argument, and also you can use property assignments, for example:looks for a type
FooAttributeorFoo, with a constructor that takes anintand astring, and has a propertyBarthat can be assigned anint.Most attributes don’t do anything directly, but you can write code that inspects types for attributes (via reflection), which is a very convenient way of library code knowing how to work with a type.
For example:
this reconfigures
XmlSerializer(which checks for the above attributes) to serialize the type as:where without the attributes it would be: