List Info

Thread: Guid Constructor




Guid Constructor
user name
2006-12-14 16:15:23
There's also a technical reason: System.Guid is a value type
and, as
such, it can't have an explicit parameterless constructor.
All the
fields are zero-initialized by the CLR unless a constructor
taking an
argument is called.

-Dan

-----Original Message-----
From: Discussion of development on the .NET platform using
any managed
language [mailtoOTNET-CL
RDISCUSS.DEVELOP.COM] On Behalf Of Efran
Cobisi
Sent: Thursday, December 14, 2006 2:50 AM
To: DOTNET-CLRDISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-CLR] Guid Constructor

I think this was a design driven decision. Since creating a
new Guid is
a time consuming task and one usually would not expect to
perform a
lenghty operation inside a constructor, calling a method
would be more
appropriate in this case.

HTH,

Efran Cobisi
http://www.cobisi.com

Brady Kelly wrote:
> Why do I have to use the Guid.NewGuid static method to
create a new,
random
> Guid?  A default, parameterless constructor seems an
ideal means to do
this.
>
>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>
> View archives and manage your subscription(s) at
http://discuss.develop.com

>

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com


===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Guid Constructor
user name
2006-12-14 16:15:32
Interesting enough, System.Guid has a private constructor
which accepts
a boolean argument which, basically, says if the newly
created instance
of the struct should be zero-initialized or generated by the
system.

Efran Cobisi
http://www.cobisi.com

Dan Farino wrote:
> There's also a technical reason: System.Guid is a value
type and, as
> such, it can't have an explicit parameterless
constructor. All the
> fields are zero-initialized by the CLR unless a
constructor taking an
> argument is called.
>
> -Dan
>
> -----Original Message-----
> From: Discussion of development on the .NET platform
using any managed
> language [mailtoOTNET-CL
RDISCUSS.DEVELOP.COM] On Behalf Of Efran
> Cobisi
> Sent: Thursday, December 14, 2006 2:50 AM
> To: DOTNET-CLRDISCUSS.DEVELOP.COM
> Subject: Re: [DOTNET-CLR] Guid Constructor
>
> I think this was a design driven decision. Since
creating a new Guid is
> a time consuming task and one usually would not expect
to perform a
> lenghty operation inside a constructor, calling a
method would be more
> appropriate in this case.
>
> HTH,
>
> Efran Cobisi
> http://www.cobisi.com
>
> Brady Kelly wrote:
>
>> Why do I have to use the Guid.NewGuid static method
to create a new,
>>
> random
>
>> Guid?  A default, parameterless constructor seems
an ideal means to do
>>
> this.
>
>> ===================================
>> This list is hosted by DevelopMentor(r)  http://www.develop.com
>>
>> View archives and manage your subscription(s) at
>>
> http://discuss.develop.com

>
>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com

>
> ===================================
> This list is hosted by DevelopMentorŪ  http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com

>

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )