Casting to inhering type from inherited type
-
livez wrote:
XmlDocument doc = new XmlDocument(); t = (test)doc;
XmlDocument doc = new test();
test t = (test) doc;I am not saying any more.
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008) -
I think you need to study inheritance and polymorphism a bit more. It takes a while to get to understand it, but once you do, it all seems natural.
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008) -
My manners are irrelevant. I do not like to spoon-feed people.
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008)leppie wrote:
My manners are irrelevant.
Well said, Seven! :-D
Recent blog posts: * Introduction to LINQ to XML (Part 1) - (Part 2) - (part 3) My website | Blog
-
livez wrote:
work on your manners a bit
His responses appeared to be quite polite. Curt, for sure, but polite.
Recent blog posts: * Introduction to LINQ to XML (Part 1) - (Part 2) - (part 3) My website | Blog
-
[Message Deleted]
Why was the message deleted? Because the OP said the proposed solution didn't work? That's not a very good reason as now no one else who runs into the same (or similar) problem will know not to try that approach.
Scott. —In just two days, tomorrow will be yesterday. —Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[Forum Guidelines] [Articles] [Blog]
-
leppie wrote:
My manners are irrelevant.
Well said, Seven! :-D
Recent blog posts: * Introduction to LINQ to XML (Part 1) - (Part 2) - (part 3) My website | Blog
-
livez wrote:
work on your manners a bit
His responses appeared to be quite polite. Curt, for sure, but polite.
Recent blog posts: * Introduction to LINQ to XML (Part 1) - (Part 2) - (part 3) My website | Blog
-
This is what I tried:
class test : XmlDocument
{
public test()
{} public void testing () { test t = new test(); XmlDocument doc = new XmlDocument(); t = (test)doc; } }
in general these kinds of casts will only work towards the base class. ie a test is an XmlDocument but an XmlDocument is Not necessarily a test. you could use the "as" operator t = doc as test; this will return t == null if doc is not of type test. If you know how to convert an XmlDocument into a test then you could create a cast for it public static explicit operator Test(XmlDocument doc) { //your conversion algorithm here } HTH Russ