Is there any difference between [Serializable] and [Serializable ()] in C #?

I came across examples using either of the two notation. I can’t find anything about this that says which one is common, why 2 notations are allowed, and if there is any subtle difference between them.

anybody an idea?

+5
source share
3 answers

No, there is no functional difference.

Why two different styles, you ask? The first notation is allowed for brevity. 2nd notation is allowed because some attributes take parameters:

[Category("Foobar related methods.")]
public void Foo()
{
}

, [Serializable] [SerializableAttribute()] - # , .

+23

, . [Serializable] - [Serializable()], # , .

, [SerializableAttribute()], .

+9

both use c'tor by default, there is no difference.

+6
source

All Articles