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 6194605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:19:30+00:00 2026-05-24T03:19:30+00:00

I’m relatively new to C# – but come from a C/C++ background. I need

  • 0

I’m relatively new to C# – but come from a C/C++ background.

I need a data type (class) that is similar to DataTable, but allows the stored columns to hold “simple” types (int, float, boolean, [string]) AS WELL as data of the same type (so that a column could hold another table which also has columns that stores tables etc).

In C++ parlance, what I am describing is something along these lines:

typedef union { /*... */ } ValueType;
typedef std::vector<ValueType> ColumnValues; 

class Column
{
    private:
       std::string m_name ;
       ColumnValues m_values;

    public:
       Column(const std::string& name);
       // ...
}

class Table
{
   private:
      std::string m_name;
      std::vector<Column> m_cols;

    public:
       Table(const std::string& name, const std::vector<Column> *cols_ptr = NULL);
       // ...   
};

A column can hold any valid data type – which includes a Table data type (hence the implicit infinite nesting capability).

My initial thought approach was to inherit from DataTable – but thought I’d com in here to check if:

  1. If such a class already exists somewhere (either in the .Net library or elsewhere)
  2. if that is the correct way of going about it

In the event that I will need to “roll my own”, I would appreciate some pointers (i.e. code snippets) to help me get started.

[Edit]

Proposed usage: I intend to use this data type primarily to serialize objects in my library (so I can send them in message packets etc), but also, so I can use them as a kind of data dictionary that allows me to store data of arbitrary complexity.

  • 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-24T03:19:30+00:00Added an answer on May 24, 2026 at 3:19 am

    I am not sure if I’m understanding corrrectly, but what is preventing you from creating a DataColumn with DataTable as it’s type?

    Something like the following:

    DataTable myTableOfTables = new DataTable("TableOfTables);
    myTableOfTables.Columns.Add(new DataColumn("Table", typeof(DataTable)));
    

    Now you can go ahead and do the following:

    myTableOfTables.Rows.Add(myTableOfTables.NewRow()[0] = new DataTable("NestedTable"));
    

    And sure enough if you check in the immeadiate window:

    ? myTableOfTables.Rows[0][0]
    

    You will get:

    {NestedTable}
        base {System.ComponentModel.MarshalByValueComponent}: {NestedTable}
        CaseSensitive: false
        ChildRelations: {System.Data.DataRelationCollection.DataTableRelationCollection}
        Columns: {System.Data.DataColumnCollection}
        Constraints: {System.Data.ConstraintCollection}
        DataSet: null
        DefaultView: {System.Data.DataView}
        DisplayExpression: ""
        ExtendedProperties: Count = 0
        HasErrors: false
        IsInitialized: true
        Locale: {es-ES}
        MinimumCapacity: 50
        Namespace: ""
        ParentRelations: {System.Data.DataRelationCollection.DataTableRelationCollection}
        Prefix: ""
        PrimaryKey: {System.Data.DataColumn[0]}
        RemotingFormat: Xml
        Rows: {System.Data.DataRowCollection}
        Site: null
        TableName: "NestedTable"
    

    So you already have a class that allows this kind of structure: DataTable

    If what you want is one DataColumn that is able to contain whatever value, be it an int, a string or what have you, then simply define its type as object.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a text area in my form which accepts all possible characters from
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and

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.