G
Guest
Hello,
i have a problem to cast an object - hope somebody can help me. thx
namespace CopyTest
{
public class A
{
public int a;
}
public class B:A
{
public int b;
}
class TestClass
{
[STAThread]
static void Main(string[] args)
{
A a = new A();
B b = new B();
a.a = 1;
b = a; // <- error
// An unhandled exception of type 'System.InvalidCastException' occurred in
CopyTest.exe
// Additional information: Specified cast is not valid.
}
}
}
i have a problem to cast an object - hope somebody can help me. thx
namespace CopyTest
{
public class A
{
public int a;
}
public class B:A
{
public int b;
}
class TestClass
{
[STAThread]
static void Main(string[] args)
{
A a = new A();
B b = new B();
a.a = 1;
b = a; // <- error
// An unhandled exception of type 'System.InvalidCastException' occurred in
CopyTest.exe
// Additional information: Specified cast is not valid.
}
}
}