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:
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: