[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

How do I decalre a new DataTable whose name is based on a string value

I had a string called zDefinedType, I want my DataTable to be able to dynamically name itself after the string.

PSEUDOCODE

string zDefinedType = "Generic";
DataTable textValueOf(zDefinedType) = New DataTable();

Any Ideas?
0
tatton777
Asked:
tatton777
  • 2
2 Solutions
 
athapaCommented:
I doubt that is possible. You could create a new table and add that to hashtable with zDefineType as a key and then you could access that table with that name. I'm not sure what exactly are you trying to do. If you could provide more info on what you are trying to achieve then I could help more.

AT
0
 
AGBrownCommented:
Does this not work?
      string strTableName = "test";
      DataTable myTable = new DataTable(strTableName);
      Console.WriteLine("table Name: {0}", myTable.TableName);

Andy
0
 
AGBrownCommented:
Up to tatton777 really; I think both athapa and myself offer solutions, though we both needed more info if they weren't sufficient.

A.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now