+ Reply to Thread
Results 1 to 2 of 2

Thread: Adding more than one value into one list record

  1. #1

    Adding more than one value into one list record

    I want to create a list that can hold multiple information in one record.
    I can't use the normal list as it can only hold one information.

    Is there any other way to do that ?
    Last edited by csharpmaster; 10-29-2012 at 11:24 PM.

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    35
    I used to use lists and used to split each list item[Record] by "|" for more than one value.
    i.e : Record 1 >> Value1|Value2|Value3 and so on....
    And i used to split values by "|" and that would take much more processing time.

    So i figured out a better way.

    All we would be doing is :
    - Creating a Class that holds the record`s values
    - Creating a list of that class
    - Whenever we need a specific value of a specific record we would be just calling the value Name.

    1- Create the Class :
    Code:
    public class TAG
    {
        public String Name;
        public String Value;
    };
    2- How to store ?
    Code:
    var tags = new List<TAG>();
    tags.Add(new TAG{Name = "any Name", Value = "A value"});
    3- How to retrieve information ?
    Code:
    // Suppose we need to get the Name of Record number 3 ?
    var tagname5 = tags[3].Name;

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts