Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. data stucture

data stucture

Scheduled Pinned Locked Moved C#
help
6 Posts 3 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mcrooks
    wrote on last edited by
    #1

    I am trying to implement a structure that starts with a root class which points to many different nodes. Each node then points to two unique classes. I would like to be able to add nodes and hence the two classes associated with each node. Any help on this would be greatly appreciated. cheers mike

    N L 2 Replies Last reply
    0
    • M mcrooks

      I am trying to implement a structure that starts with a root class which points to many different nodes. Each node then points to two unique classes. I would like to be able to add nodes and hence the two classes associated with each node. Any help on this would be greatly appreciated. cheers mike

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      So you just want a class represenative of your root that contains an array of each unique class?

      - Nick Parker Microsoft MVP - Visual C#
      My Blog | My Articles

      M 1 Reply Last reply
      0
      • M mcrooks

        I am trying to implement a structure that starts with a root class which points to many different nodes. Each node then points to two unique classes. I would like to be able to add nodes and hence the two classes associated with each node. Any help on this would be greatly appreciated. cheers mike

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Something like this?

        class RootNode
        {
        Node[] nodes;
        }

        class Node
        {
        UniqueNode1 node1 = null;
        UniqueNode2 node2 = null;
        }

        Insertion functions, array initialization and all the stuff is left as an exercise :p regards

        M 1 Reply Last reply
        0
        • N Nick Parker

          So you just want a class represenative of your root that contains an array of each unique class?

          - Nick Parker Microsoft MVP - Visual C#
          My Blog | My Articles

          M Offline
          M Offline
          mcrooks
          wrote on last edited by
          #4

          I am knew to this coding thing so could you be a bit more specific? I basically want to store "player" data in a struct (i guess) or class. I then want to add struct's or classes to the "player" namely "assesment dates". Attached to each date are two struct's or classes that contain various assesment data. Is that what you thought in the first place? thanks for your response regards mike

          1 Reply Last reply
          0
          • L Lost User

            Something like this?

            class RootNode
            {
            Node[] nodes;
            }

            class Node
            {
            UniqueNode1 node1 = null;
            UniqueNode2 node2 = null;
            }

            Insertion functions, array initialization and all the stuff is left as an exercise :p regards

            M Offline
            M Offline
            mcrooks
            wrote on last edited by
            #5

            I am knew to this coding thing so could you be a bit more specific? I basically want to store "player" data in a struct (i guess) or class. I then want to add struct's or classes to the "player" namely "assesment dates". Attached to each date are two struct's or classes that contain various assesment data. Is that what you thought in the first place? thanks for your response regards mike

            L 1 Reply Last reply
            0
            • M mcrooks

              I am knew to this coding thing so could you be a bit more specific? I basically want to store "player" data in a struct (i guess) or class. I then want to add struct's or classes to the "player" namely "assesment dates". Attached to each date are two struct's or classes that contain various assesment data. Is that what you thought in the first place? thanks for your response regards mike

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              mcrooks wrote:

              I basically want to store "player" data in a struct (i guess) or class. I then want to add struct's or classes to the "player" namely "assesment dates". Attached to each date are two struct's or classes that contain various assesment data. Is that what you thought in the first place?

              Yes, it's almost the same, but a list will be enough for the players and assesment dates. Something like that:

              List<Player> players = new List<Player>();

              class Player
              {
              public name = "Some Name";
              public List<AssesmentData> data = new List<AssesmentData>();
              }

              class AssesmentData
              {
              // object can virtually be anything, can be casted as needed
              public object data1 = ...
              public object data2 = ...
              }

              You can modify it like that

              // create our player
              Player player1 = new Player();
              player1.name = "Peter Someone";

              // create two tasks
              AssesmentData task1 = new AssesmentData();
              task1.data1 = "Some string";
              task1.data2 = 50;

              AssesmentData task2 = new AssesmentData();
              task2.data1 = 3.3f
              task2.data2 = @"C:\Some\Path";

              player1.data.Add(task1;
              player1.data.Add(task2);

              players.Add(player1);

              regards

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups