I have seen attributes, specifically Serializable declared in 2 ways and was
wondering if anyone had any insight on the differance if there is any. These
2 ways are [Serializable] and [Serializable()]. Does the addition of the
parenthesis do anything? Is this calling a constructor? Both seem to have the
same effect in the end, but it seems like they should do something differnt?

Re: () in attribute declaration by Henning

Henning
Wed Mar 12 12:10:31 CDT 2008

Hi,

it's the same. You can just omit the parentheses if you aren't specifying
any parameters.

Kind regards,
Henning Krause

"wdudek" <wdudek@newsgroup.nospam> wrote in message
news:B8494826-BA6F-45BA-9CA3-F818EE1C55D5@microsoft.com...
>I have seen attributes, specifically Serializable declared in 2 ways and
>was
> wondering if anyone had any insight on the differance if there is any.
> These
> 2 ways are [Serializable] and [Serializable()]. Does the addition of the
> parenthesis do anything? Is this calling a constructor? Both seem to have
> the
> same effect in the end, but it seems like they should do something
> differnt?


RE: () in attribute declaration by stcheng

stcheng
Wed Mar 12 20:48:21 CDT 2008

Hi wdudek,

both syntax is correct and there is no difference between them. You can
think them as the two declaration that one is use the default constructor
implicitly while another call the constructor explicitly(parameterless
constructor).

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: =?Utf-8?B?d2R1ZGVr?= <wdudek@newsgroup.nospam>
>Subject: () in attribute declaration
>Date: Wed, 12 Mar 2008 09:05:01 -0700

>
>I have seen attributes, specifically Serializable declared in 2 ways and
was
>wondering if anyone had any insight on the differance if there is any.
These
>2 ways are [Serializable] and [Serializable()]. Does the addition of the
>parenthesis do anything? Is this calling a constructor? Both seem to have
the
>same effect in the end, but it seems like they should do something
differnt?
>


RE: () in attribute declaration by wdudek

wdudek
Mon Mar 17 09:40:01 CDT 2008

Thanks everyone, I kind of figured as much, but it's good to know for sure.

""Steven Cheng"" wrote:

> Hi wdudek,
>
> both syntax is correct and there is no difference between them. You can
> think them as the two declaration that one is use the default constructor
> implicitly while another call the constructor explicitly(parameterless
> constructor).
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
> --------------------
> >From: =?Utf-8?B?d2R1ZGVr?= <wdudek@newsgroup.nospam>
> >Subject: () in attribute declaration
> >Date: Wed, 12 Mar 2008 09:05:01 -0700
>
> >
> >I have seen attributes, specifically Serializable declared in 2 ways and
> was
> >wondering if anyone had any insight on the differance if there is any.
> These
> >2 ways are [Serializable] and [Serializable()]. Does the addition of the
> >parenthesis do anything? Is this calling a constructor? Both seem to have
> the
> >same effect in the end, but it seems like they should do something
> differnt?
> >
>
>