Re: Difference between ArrayList and List<object& gt; ?
On 20 Oct 2006 01:31:11 -0700, "Murat Ozgur" <muratozgur@gma il.com>
wrote:
Is there any difference between ArrayList and List<object? Which
>one should I use ?
I think List< object should be better, because it uses generics; so
it is type safer than ArrayList (in which you can put everything
derived from base object class).
Re: Difference between ArrayList and List<object& gt; ?
Not much difference really, I'd probably use List<Objectbeca use then
it's clear to other people that your intention was to store a list of
Objects (or various derivative types), rather than a list of some other
specific type that would always need explicitly casting.
Re: Difference between ArrayList and List<object& gt; ?
* Murat Ozgur wrote:
Hello,
>
Is there any difference between ArrayList and List<object? Which
one should I use ?
>
List<objectis type safe and more efficient since it doesn't require
boxing operations (converting a value type to a reference type, and vice
versa) so it could be more efficient depending on what you store in your
list.
Re: Difference between ArrayList and List<object& gt; ?
"Angel Of Death" <afklj@23o.1f.c o.ukwrote in message
news:ehd5ev$50n $2@custnews.inw eb.co.uk...
>* Murat Ozgur wrote:
>Hello,
>>
> Is there any difference between ArrayList and List<object? Which
>one should I use ?
>>
>
List<objectis type safe and more efficient since it doesn't require
boxing operations (converting a value type to a reference type, and
vice
versa) so it could be more efficient depending on what you store in
your
list.
Claiming that "List<objec tis type safe" is sort of silly.
Since it has a type of object that kind of wipes out type saftey since
everything is an object.
A better overall suggestion would be to use List<SomeType>. Then you can
talk about type safe.
Re: Difference between ArrayList and List<object& gt; ?
MrAsm wrote:
On 20 Oct 2006 01:31:11 -0700, "Murat Ozgur" <muratozgur@gma il.com>
wrote:
>
> Is there any difference between ArrayList and List<object? Which
>one should I use ?
>
I think List< object should be better, because it uses generics; so
it is type safer than ArrayList (in which you can put everything
derived from base object class).
>
No, there is no difference in type safety. A reference to an object is
not more type safe just because you use generics.
Re: Difference between ArrayList and List<object& gt; ?
"Göran Andersson" <guffa@guffa.co mwrote in message
news:eOGS1jY9GH A.3396@TK2MSFTN GP04.phx.gbl...
>I think List< object should be better, because it uses generics; so
>it is type safer than ArrayList (in which you can put everything
>derived from base object class).
>
No, there is no difference in type safety. A reference to an object is not
more type safe just because you use generics.
I think what he means is that an ArrayList can store multiple types, and
there's no checking to ensure that every element of the array is the same
type as every other element.
Perhaps a more significant benefit would be "type convenient". :)
As you note, C# is type safe no matter how you store a reference. But one
nice thing about the generic types is that because the type is explicitly
stated with the collection, you don't need to cast things as they are
referenced from the collection.
Re: Difference between ArrayList and List<object& gt; ?
Peter Duniho wrote:
"Göran Andersson" <guffa@guffa.co mwrote in message
news:eOGS1jY9GH A.3396@TK2MSFTN GP04.phx.gbl...
>>I think List< object should be better, because it uses generics; so
>>it is type safer than ArrayList (in which you can put everything
>>derived from base object class).
>No, there is no difference in type safety. A reference to an object is not
>more type safe just because you use generics.
>
I think what he means is that an ArrayList can store multiple types, and
there's no checking to ensure that every element of the array is the same
type as every other element.
The exact same is true for List<objecttoo.
Perhaps a more significant benefit would be "type convenient". :)
>
As you note, C# is type safe no matter how you store a reference. But one
nice thing about the generic types is that because the type is explicitly
stated with the collection, you don't need to cast things as they are
referenced from the collection.
Yes, that is true for a list of a specific type, like List<int>, but not
for List<object>.
Re: Difference between ArrayList and List<object& gt; ?
"Göran Andersson" <guffa@guffa.co mwrote in message
news:eQAoYCZ9GH A.4712@TK2MSFTN GP03.phx.gbl...
>I think what he means is that an ArrayList can store multiple types, and
>there's no checking to ensure that every element of the array is the same
>type as every other element.
Comment