I'm trying to pass a structure to a sub/void to fill it with data. In C# this works fine by doing
[TestFixture]
public class Boxing
{
[Test]
public void BoxingValue()
{
var res = (object)new Test();
SomeVoid(res);
Assert.AreEqual(2, ((Test)res).Id);
}
public static void SomeVoid(object b)
{
var f = b.GetType().GetField("Id");
f.SetValue(b, 2);
}
public struct Test
{
public int Id;
}
}
This code passes the test in C# in vb thoug
<Test> Public Sub StructTest()
Dim s As Object
s = CObj(New Test)
A(s)
Assert.AreEqual(2, CType(s, Test).Id)
End Sub
Public Sub A(val As Object)
Dim f = val.GetType().GetField("Id")
f.SetValue(val, 2)
End Sub
Public Structure Test
Public Id As Integer
End Structure
Does anyone have a explanation for this..
STRANGE?