Newbies Pay Attention

Ok, this may be common knowledge for most of you, but for the rest listen up:

I spent the past 2 days playing with collections. My opinion: They suck. I can't wait for generics, because there is entrely way too much coding that you have to do to get a collection working. And would there be easy-to-follow samples ANYWHERE about them.... noooo. The closest I came was Darren Nimike's example on ShowUsYourCode. {Darren, a brief note: update to ASP.NET ;) }

So I wanted to be able to access an item in the collection by a value and not by an index. I started by inheriting from CollectionBase, thenĀ I tried overloading my Item property with one that accepts a string, and returns the following information:

List(List.IndexOf(String))

I was of the impression that this would work. It didn't. I didn't really feel like digging around a whole lot more for it, because I'm trying to get GenX.NET wrapped up already, and I just wanted to hold key/value pairs anyways. So I killed all my code, and replaced it with one line underneath my collection definition:

Inherits NameValueCollection

I couldn't be happier. It does exactly what I need it to... no fuss, no mess. The whole collections issue is definitely going to warrant an article. It's just too damned difficult the way it is.

7 Comments

  • If I remember correctly, you can't do indexer overloading in C# or VB.Net(only one indexer per class), only C++.Net lets you do that. Sucks, don't it?

  • Roy: Sure you can, at least you can in C#.

  • <Sarcasm>





    Wow...its just soooo hard to do anything nowadays...yikes...I have to write more than 5 lines of code for this program to work...oh, nooooo I have to use my head a little...ahhhhh...I though Microsoft had eliminated all the thinking associated with programming!!!!!!!!





    </Sarcasm>





    Generics will be nice..but until then, things aren't really that bad!

  • I don't mind coding. What I mind is a lack of coherent documentation.

  • Robert,





    I'm wondering if the lack of coherent documentation comment is directed toward CodeSmith? If so, could you please elaborate on what you thought was missing and how I could make it better. Thanks!





    Eric J. Smith

  • Nope, it was directed towards the Framework. I don't use code generators in that way. I have my good friend Visio, who is going to be doing the bulk of my code generation from now on.





    I will however, be evaluating it in the near future for one of my Builder.com articles, and I will give you feedback at that time.





    Thanks, Eric!

  • OK, had me worried... I know the documentation is not great, but I didn't think it was incoherent! :-) Please feel free to ask me any questions.



    Thanks!

    Eric J. Smith

Comments have been disabled for this content.