Alex Rivera | Logout

What is [ and ] in c#?

Asked 2010-08-24T13:43:22.130
10

What is the [ and ] in c#? what is it used for? what does it mean?

example

[DefaultValue(null)]
[JsonName("name")]
public string Name
{
    get
    {
        if (this.name == null)
        {
            return String.Empty;
        }
        return this.name;
    }
}
c#
Edit
Report

1 Answer

3

Those are used for attributes in C#, are in a way like java annotations. Attributes are used by reflection. Attributes are used to give metainformation. You can check the following links: http://oreilly.com/catalog/progcsharp/chapter/ch18.html http://www.codeguru.com/csharp/.net/net_general/assemblies/article.php/c7009 to see how can used.

answered 2010-08-24T13:49:26.763

Your Answer