我是C#学习者。我遇到了德尔马。当我取消装箱时(将对象变量转换为int变量并遇到错误)。我的代码:
namespace test1
{
public struct Tst
{
public int x;
public int y;
}
class Program
{
static void Main(string[] args)
{
var v1 = new Tst();
v1.x = 5;
Object o1 = v1;
Tst ll = (Tst)o1;
((Tst)o1).x = 10; // here I have an error. I cant understand why I cant do it.
Console.WriteLine(ll.x);
Console.ReadLine();
}
}
}