C#中的数据类型查找

时间:2011-11-16 15:37:37

标签: type-conversion metadatatype

我在字符串数组中有10个数据。在这10个数据中,每个数据可以是整数/字符串/双/日期时间格式。基于这10种数据类型,我们必须找到通用的数据类型。

Eg1:string [" 10"," 20"," 3"," 45"] - > o / p:int。

Eg2:字符串[" 10"," 2o"," 3"," 4"," 5.0&# 34;," 4"," 56"] - > o / p:浮动。

Eg3:string [" 10"," 20.5"," ten"," 45"] - > o / p:string

1 个答案:

答案 0 :(得分:0)

迭代:TryParse double,TryParse Int,TryParse DateTime或string。完成。