小编Pra*_*iya的帖子

在c#中使用字符串数据类型列表创建元组

我需要从字符串中的数据类型列表创建元组,但没有得到任何解决方案。

这是我想要做的示例。

string[] dataType = {"int", "float", "datetime"};

//I want to create list like this but dynamically datatype come from db.
//List<Tuple<int, string, string>> list = new List<Tuple<int, string, string>>(); 

List<Tuple<dataType[0],dataType[1], dataType[2]>> list = new List<Tuple<dataType[0],dataType[1], dataType[2]>>();
//Here datatype value is in string so I want to convert string to actual datatype.
Run Code Online (Sandbox Code Playgroud)

或者,如果对此有任何替代解决方案,请指导我。

c# tuples list

5
推荐指数
1
解决办法
131
查看次数

标签 统计

c# ×1

list ×1

tuples ×1