質問

The MSDN documentation about the DataMemberAttribute class shows a example below.

Sometimes brackets are set and sometimes are not. What is the reason behind?

Example:

[DataMember()]
    public string FirstName;

 [DataMember]
    public string LastName
    {
        get { return LastNameValue; }
        set { LastNameValue = value; }
    }
役に立ちましたか?

解決

This is a C# syntax issue. It has nothing to do with these particular classes.

Brackets are optional for attributes if you do not pass arguments to the constructor of the attribute.

I recommend that you decide which style you like and stick to it.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top