Schavey
01-25-2004, 01:40 PM
I want to show how to change the value of a member variable in a boxed item.
The C# code works (from a course given by U2U).
My 'translation' in VB.NET doesn't work! I don't get an error, but the value of the
point remains the same!
What am I doing wrong?
Thank you
Pierre Schavey
using System;
using System.Drawing;
namespace BoxingStruct
{ class Class1
{ static void Main()
{
Point p = new Point(10, 20);
object op1 = p;
Console.WriteLine(p);
op1.GetType().GetProperty("X").SetValue(op1, 777, null);
Console.WriteLine(p);
Console.ReadLine();
}
}
}
Imports System.Text
Imports System.Drawing
Module BoxingTest
Sub Go5()
Dim p As Point = New Point(10, 20)
Dim op1 As Object
op1 = p
Console.WriteLine(p)
op1.GetType().GetProperty("X").SetValue(op1, 777, Nothing)
Console.WriteLine(p)
Console.ReadLine()
End Sub
Sub Main()
Go5()
End Sub
End Module
The C# code works (from a course given by U2U).
My 'translation' in VB.NET doesn't work! I don't get an error, but the value of the
point remains the same!
What am I doing wrong?
Thank you
Pierre Schavey
using System;
using System.Drawing;
namespace BoxingStruct
{ class Class1
{ static void Main()
{
Point p = new Point(10, 20);
object op1 = p;
Console.WriteLine(p);
op1.GetType().GetProperty("X").SetValue(op1, 777, null);
Console.WriteLine(p);
Console.ReadLine();
}
}
}
Imports System.Text
Imports System.Drawing
Module BoxingTest
Sub Go5()
Dim p As Point = New Point(10, 20)
Dim op1 As Object
op1 = p
Console.WriteLine(p)
op1.GetType().GetProperty("X").SetValue(op1, 777, Nothing)
Console.WriteLine(p)
Console.ReadLine()
End Sub
Sub Main()
Go5()
End Sub
End Module