Search:
Namespaces
Discussions
.NET v1.1
Feedback
Strong-Typed Resizable Arrays
Messages
Related Types
This message was discovered on
microsoft.public.dotnet.framework
.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...
Alex Maghen (VIP)
Hi. I'm trying to find the absolute most lightweight, efficient array type
that supports:
1. Strongly-typed entries (e.g. not all items of type "Object")
2. Ability to Add() and Remove()
I see that the C# built-in array type doesn't support resizing. The
framework
ArrayList
supports resizing but doesn't seem to allow a fixed entry
type. How do I do this?
Alex
Reply to this message...
Jon Skeet [C# MVP] (VIP)
Alex Maghen <
Click here to reveal e-mail address
> wrote:
[Original message clipped]
The "real answer" is coming in Whidbey - VS.NET 2005 - in the form of
generics. If that's too long to wait, I believe there are various
"properly strongly typed" collection class generators available on the
net, that will give an ArrayList-like interface with a strongly typed
backing array. (That gets round the boxing problem for value types.)
--
Jon Skeet - <
Click here to reveal e-mail address
>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Reply to this message...
Alex Maghen (VIP)
Wow... really? I mean... wow. Doesn't that seem like a somewhat... starnge
thing not to have as integral to... y'know what? Far be it from me to
criticize. Not like I wrote .NET or anything. Okay, thanks.
Alex
"Jon Skeet [C# MVP]" wrote:
[Original message clipped]
Reply to this message...
Jon Skeet [C# MVP] (VIP)
Alex Maghen <
Click here to reveal e-mail address
> wrote:
[Original message clipped]
It would certainly have been nice if generics had been in 1.1, but to
be honest I've never had any actual *problems* from using
ArrayList
,
other than the performance concerns of boxing value types. The type
safety issue is definitely something I'll be pleased not to have to
worry about, but I can't think of a single time where it's been an
actual problem for me.
--
Jon Skeet - <
Click here to reveal e-mail address
>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Reply to this message...
Jakob Christensen
I have used Chris Sells collection generator on several occasions (couldn't
wait for Whidbey). His collections use strongly typed backing arrays (as
John Skeet mentions) except for the strongly typed hashtables.
http://www.sellsbrothers.com/tools/#collectionGen
Regards, Jakob.
"Alex Maghen" wrote:
[Original message clipped]
Reply to this message...
mdb
"=?Utf-8?B?QWxleCBNYWdoZW4=?=" <
Click here to reveal e-mail address
>
wrote in news:
Click here to reveal e-mail address
:
[Original message clipped]
Choose one of:
1) If you are using (or can wait for the final release of) .NET 2.0, you
can use Generics.
2) Write your own storage class
3) If you are using strings, you can use the
StringCollection
class in
System.Collections.Specialized namespace.
-mdb
Reply to this message...
System.Collections.ArrayList
System.Collections.Specialized.StringCollection
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com