473,326 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Casting from XmlNode to an inherited calss from XmlElement

Hello,
I have an inherited class from XmlElement with this name: XmlElementCF
I have added a function in XmlElementCF that returns a XmlNode, the
node type is Element. I can cast the returned node to XmlElement but
can not cast the returned node to XmlElementCF, I am getting an error
: Specified cast is not valid.
I want to cast the returned node to my inherited class XmlElementCF.
Please Help.
Thanks
Parham

Nov 22 '05 #1
1 1806
Parham <pa***************@gmail.com> wrote:
I have an inherited class from XmlElement with this name: XmlElementCF
I have added a function in XmlElementCF that returns a XmlNode, the
node type is Element. I can cast the returned node to XmlElement but
can not cast the returned node to XmlElementCF, I am getting an error
: Specified cast is not valid.
I want to cast the returned node to my inherited class XmlElementCF.


You can't cast a reference to something which it actually isn't at
runtime.

You may want to create a constructor for XmlElementCF which takes an
XmlElement to copy data from (or just keep a reference to).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Parham | last post by:
Hello, I have an inherited class from XmlElement with this name: XmlElementCF I have added a function in XmlElementCF that returns a XmlNode, the node type is Element. I can cast the returned node...
2
by: Earl Teigrob | last post by:
I am having trouble creating an Attribute on a new node. The NodeObject.SetAttribute(x,y) method does not exist for the "RecordElement" node. What am I missing??? Earl XmlDocument d = new...
2
by: Pluto | last post by:
What is the difference between XmlNode and XmlElement? I'm trying to implement the code at http://www.devx.com/dotnet/Article/11616/0/page/3 in C# and I'm getting an error at this line:...
2
by: David Elliott | last post by:
I am creating a configuration class to read / write a standard configuration file. <?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key="ConnectionString"...
3
by: Mahesh Devjibhai Dhola | last post by:
Hi All, I want to make a custom class in c#, which extends System.Xml.XmlNode class of BCL. Now in custom class, I have implement abstract methods of XmlNode class also. Now when I am trying to...
1
by: Dominic Messenger | last post by:
I have a schema that I load into classes that mirror the schema using the XmlSerialization. The schema contains an xsd:Any that I load into 'Extra' as follows: public XmlNode Extra { get {...
5
by: Paul | last post by:
Here I have the definition of an XmlNode which is a property (PayPreference) on my Customer class containing an enum describing how the customer will pay. <PayPerference...
1
by: andrej | last post by:
hi, ich habe eine anwendung, welche ein xml document erstellt. um festzustellen, ob ein element bereits vorhanden ist, verwende ich die funktion selectsinglenode( ....) diese funktion...
5
by: Mahesh Devjibhai Dhola | last post by:
Hi All, I want to make a custom class in c#, which extends System.Xml.XmlNode class of BCL. Now in custom class, I have implement abstract methods of XmlNode class also. Now when I am trying to...
4
by: CSharper | last post by:
I am reading an XmlFile using XmlDocument and traverse through the XmlNode, as I read I need to append an attribute to the XmlNode on some conditions. I tried xmlNode.Attributes.Append() It...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.