小编Mah*_*adi的帖子

从C#中的未知类型强制转换

我有一个对象,其中包含字符串中的值和字段中的原点类型。

class myclass
{
   public string value;
   public Type type;
}
myclass s=new myclass();
s.value = "10";
s.type = typeof(int);
Type tt = s.type;
row.Value[ind]= s[0].value as tt; //i have error here
Run Code Online (Sandbox Code Playgroud)

我如何才能通过该类型转换值。

c# casting

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

标签 统计

c# ×1

casting ×1