A question that could be a candidate for an exam must be wrong

T

Tony Johansson

Hi!

Which of the alternatives at the bottom would you choose after reading
this question.
"If you want to implement a type-safe ArrayList collection for string
values and have the appropriate enumerators for it, which of the following
options would you choose?"
In this case I must say that I'm very uncertain on the answer that the
book say it's the right answer.
The book say that StringDictionary is the right choice but that must
be wrong. the right answer nust be StringCollection ?
Do you agree with me ?


--------------------------------------------------------------------------

Select the one best answer.
StringCollection
BitVector32
StringDictionary
ArrayList

//Tony
 
J

Jeroen Mostert

Which of the alternatives at the bottom would you choose after reading
this question.
"If you want to implement a type-safe ArrayList collection for string
values and have the appropriate enumerators for it, which of the following
options would you choose?"
In this case I must say that I'm very uncertain on the answer that the
book say it's the right answer.
The book say that StringDictionary is the right choice but that must
be wrong. the right answer nust be StringCollection ?
Do you agree with me ?
Yes. However, this question is out-of-date and irrelevant to begin with. The
generic collections have rendered the type-unsafe collections and the
specialized collections all but obsolete. List<string> is the practical answer.

Throw your book away, it's out-of-date *and* wrong on something simple.
Unless you really need to invest in .NET 1.x for some reason, there's no
need to stock up on this stuff.
 
T

Tony Johansson

..

Jeroen Mostert said:
Yes. However, this question is out-of-date and irrelevant to begin with.
The generic collections have rendered the type-unsafe collections and the
specialized collections all but obsolete. List<string> is the practical
answer.

Throw your book away, it's out-of-date *and* wrong on something simple.
Unless you really need to invest in .NET 1.x for some reason, there's no
need to stock up on this stuff.

Hi

This question is not in a book it is in the e-learning that microsoft supply
I can't understand why the e-learning is saying that the correct answer is
StringDictionary which is totally wrong!

//Tony
 
P

Peter Duniho

Tony said:
This question is not in a book it is in the e-learning that microsoft supply
I can't understand why the e-learning is saying that the correct answer is
StringDictionary which is totally wrong!

As I said before, you seem to be getting what you're paying for this
coursework. But that's only because you said you're not paying anything
for it. That's about what it's worth.

I don't know why the training material would provide the answer for that
question that it does, but I also don't know how many times you have to
ask questions like this and be told "that course sucks" before you go
find some real, high-quality training for the material you want to learn.

Pete
 
G

Göran Andersson

Tony said:
Hi!

Which of the alternatives at the bottom would you choose after reading
this question.
"If you want to implement a type-safe ArrayList collection for string
values and have the appropriate enumerators for it, which of the following
options would you choose?"
In this case I must say that I'm very uncertain on the answer that the
book say it's the right answer.
The book say that StringDictionary is the right choice but that must
be wrong. the right answer nust be StringCollection ?
Do you agree with me ?


--------------------------------------------------------------------------

Select the one best answer.
StringCollection
BitVector32
StringDictionary
ArrayList

//Tony

The question actually has two correct answers, but one collection is
better suited than the other.

Both the StringCollection and ArrayList are type safe and has an
enumerator that can be used to enumerate the values as strings.
Eventhough the ArrayList is not strongly typed, it's still types safe,
but the StringCollection is of course better suited as it's also
strongly typed.

The answer proposed by the book is clearly wrong, as the
StringDictionary is a hash table with key and value as strings.
 
P

Peter Duniho

Göran Andersson said:
[...]
Both the StringCollection and ArrayList are type safe and has an
enumerator that can be used to enumerate the values as strings.
Eventhough the ArrayList is not strongly typed, it's still types safe,
but the StringCollection is of course better suited as it's also
strongly typed.

Uh. ArrayList is only "type safe" in that ALL of C# is "type safe".
The only type supported by ArrayList is System.Object. And of course
since every object inherits System.Object, you can put any object of any
type into any ArrayList. That's not the usual definition of "type safe".

Also, there is no enumerator in ArrayList that is string-specific. It
is true that the "foreach" statement will attempt to cast to string if
you enumerate as strings, but there's nothing that would allow any code
to avoid the casting (e.g. if you have a need to use the enumerator
directly rather than via "foreach").

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top