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

  • SEARCH
  • Home
  • 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 8323045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:35:36+00:00 2026-06-08T23:35:36+00:00

I am trying to have an Array hold a Struct with two elements, to

  • 0

I am trying to have an Array hold a Struct with two elements, to Hold a Xml Tag name and its value.

I would like to have the array working like this:

MyArrayStruct[Count].TagName = "Bla Bla";  
MyArrayStruct[Count].TagValue = "Bla Bla Bla";

Could some please help me to get this working.


public struct TagContents
{
     String TagName;
     String TagValue;        
};

I am having problems with declaring the Array as Struct to have it working like i want, i what it to be working like the comment out code.

public void LoadXML()
{
    if (File.Exists("Data.xml"))
    {
        //Readin XML
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load("Data.xml");
        XmlNodeList dataNodes = xmlDoc.SelectNodes("//FieldData");
        //Count the nodes
        int Max = 0;
        foreach (XmlNode node in dataNodes)
        {
            Max = Max + 1;
        }

        int Count = 0;
        //TagContents MyXmlPointer = new TagContents();
        // MyXmlPointer[] ArrayNode;
        //  ArrayNode = new MyXmlPointer[Max];

        foreach (XmlNode node in dataNodes)
        {
            // ArrayNode[Count].TagName =node.SelectSingleNode("Have not found what to put here yet but will get there").Name;
            // ArrayNode[Count].TagValue =node.SelectSingleNode("Have not found what to put here yet but will get there").InnerText;                      
        }
    }
    else
    {
        MessageBox.Show("Could not find file Data.xml");
    }
}
  • 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-06-08T23:35:38+00:00Added an answer on June 8, 2026 at 11:35 pm

    Make fields public:

    public class TagContent
    {
        public String TagName;
        public String TagValue;
    };
    

    and use it, I suggest use generics (Like List<>):

    var tags = new List<TagContent>();
    
    tags.Add(new TagContent{TagName = "aaa", TagValue = "vvv"});
    
    // use it:
    // get value of 'TagName' of item 5:
    var tagname5 = tags[5].TagName;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of Bitmaps that I'm trying to convert into an array
I have an array of URL Links that I'm trying to load into a
I have an array of raw sound data samples, and I'm trying to make
I have an array of Deferred objects, which I'm trying to map to their
I have an array and I have integers in the array. I'm trying to
I am trying to sort an array. I have an array of data, where
I'm trying to build a PHP function that allows me to have an array
I am trying to work out a complicated jQuery selection. I have an array,
I have a character array and I'm trying to figure out if it matches
I have a 2d array (matrix) where I am trying to calculate the biggest

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.