Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 503753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:25:34+00:00 2026-05-13T06:25:34+00:00

I have a external library that requires a XmlNode[] instead of XmlNodeList. Is there

  • 0

I have a external library that requires a “XmlNode[]” instead of XmlNodeList. Is there a direct way to do this without iterating over and transferring each node?

I dont want to do this:

XmlNode[] exportNodes = XmlNode[myNodeList.Count];
int i = 0;
foreach(XmlNode someNode in myNodeList) { exportNodes[i++] = someNode; }

I am doing this in .NET 2.0 so I need a solution without linq.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:25:34+00:00Added an answer on May 13, 2026 at 6:25 am

    Try this (VS2008 and target framework == 2.0):

    static void Main(string[] args)
    {
        XmlDocument xmldoc = new XmlDocument();
        xmldoc.LoadXml("<a><b /><b /><b /></a>");
        XmlNodeList xmlNodeList = xmldoc.SelectNodes("//b");
        XmlNode[] array = (
            new System.Collections.Generic.List<XmlNode>(
                Shim<XmlNode>(xmlNodeList))).ToArray();
    }
    
    public static IEnumerable<T> Shim<T>(System.Collections.IEnumerable enumerable)
    {
        foreach (object current in enumerable)
        {
            yield return (T)current;
        }
    }
    

    Hints from here: IEnumerable and IEnumerable(Of T) 2

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a BSD socket created with following code (it's in external library that
I have a flash movie that requires some JavaScript from an include file but
Working on a project that requires that I am able to pickle the container
I'm doing a Java application that requires to use a web browser inside the
I've built a web part for Sharepoint that retrieves data from an external service.
I know that there are already several questions on StackOverflow about std::string versus std::wstring
In native development, you can produce libraries - .so, .dll etc - that other
The program requires an input of an arbitrary large unsigned integer which is expressed
I'd like to run some NUnit unit tests against a class in a .Net

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.