Svyatoslav wrote:
I have a problem with XmlNodes and my stack.
It looks something like this:
//declarations
XmlNode node, new_node;
Stack MyStack = new Stack();
//code
MyStack.Push(node);
new_node=MyStack.Pop();
The last line delivered an error like this:
Cannot implicitly convert type 'object' to 'System.Xml.XmlNode'
You need to cast what the stack gives you e.g.
new_node = (XmlNode)MyStack.Pop();
In .NET 2.0 there will be generics and type safe collections but in .NET
1.x the stack can store all kind of different objects so if you get an
object from the stack you need to cast it to the type you want. Of
course that means in general if you put different kind of objects in
your stack that a cast can fail so use exception handling to cover that.
--
Martin Honnen
http://JavaScript.FAQTs.com/