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