U
U
Untiwe2021-09-27 16:07:21
C++ / C#
Untiwe, 2021-09-27 16:07:21

Why arguments in square brackets before class fields?

Sometimes, before declaring a class field, or even the class itself, you can see the arguments in [square brackets]
example of serialization from meatint

[Required]
public string Id { get; set; }
[Required]
[StringLength(50, MinimumLength=3)]
public string Name { get; set; }
[Required]
[Range(1, 100)]
public int Age { get; set;


Or an example from the WFC documentation
[ServiceContract]
public interface IService
{
    [OperationContract]
    [WebGet]
    string EchoWithGet(string s);

    [OperationContract]
    [WebInvoke]
    string EchoWithPost(string s);
}


Logically, it is clear that this is some kind of wrapper that expands the functionality. But what is this design and where can I read about it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2021-09-27
@Untiwe

Attributes (C#)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question