.NETGURU
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




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification