Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is [ and ] in c#?

Tags:

c#

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;
    }
}
like image 309
001 Avatar asked Aug 24 '10 13:08

001


People also ask

What is & operator in C?

The & (bitwise AND) in C or C++ takes two numbers as operands and does AND on every bit of two numbers. The result of AND is 1 only if both bits are 1. The | (bitwise OR) in C or C++ takes two numbers as operands and does OR on every bit of two numbers. The result of OR is 1 if any of the two bits is 1.

How is && used in C?

Logical AND operator: The '&&' operator returns true when both the conditions under consideration are satisfied. Otherwise it returns false. For example, a && b returns true when both a and b are true (i.e. non-zero).


1 Answers

That is an Attribute. By themselves they do nothing at all, they just decorate code. But code can discover attributes and react to them at runtime.

like image 61
Matt Greer Avatar answered Oct 05 '22 21:10

Matt Greer