PDA

View Full Version : MCTS practice question - adding objects of different types into a linkedlist


MattyJim
11-11-2009, 04:08 PM
Hello!


I've just started to study towards my MCTS (70-536) using C#, and have come across a confusing practice question in the Microsoft .NET Framework - Application Development Foundation Self-Paced Training Kit (2nd Edition).

The question reads:

"Create a linked-list generic class that enables you to create a chain of
objects of different types"

I've managed to do this by creating a new generic type that extends the
LinkedList class (and then passing objects of different types into it), but it
doesn't really accomplish anything more than can be achieved simply by
adding objects of different types directly to an instance of LinkedList:


/* -- this seems to achieve the same thing -- */
string test1 = "this is the first string";
string test2 = "this is the second string";
string[] test3 = { "one", "two" };

LinkedList<object> mt = new LinkedList<object>();
mt.AddLast(test1);
mt.AddLast(test2);
mt.AddLast(test3);


I think that I'm looking at this in the wrong way, but can anybody shed any
light on the matter? :confused:

Trinithis
11-12-2009, 03:15 AM
Sounds like they want you to write the class from scratch, not use the existing LinkedList class and instantiate an list with it.

MattyJim
11-13-2009, 12:45 AM
Hmm...yeah, that could be it.

I'll take that direction and see what I can come up with.



Thanks! :)