Name: sadimir 2011-12-02 14:15
Switching from c++ to c# and derping hard.
The error:
"An unhandled exception of type 'System.NullReferenceException' occurred in sharp_TEST.exe
Additional information: Object reference not set to an instance of an object."
The masterpiece:
class Program {
static void Main() {
Polygon4[] x = new Polygon4[20];
foreach (Polygon4 face in x)
{
face.print();
}
}
}
//////////////////////////////
class Polygon4
{
Vertex3D a, b, c, d;
public Polygon4()
{
a = new Vertex3D();
b = new Vertex3D();
c = new Vertex3D();
d = new Vertex3D();
}
public void print()
{
a.print();
b.print();
c.print();
d.print();
}
}
/////////////////////////////
class Vertex3D
{
float x, y, z;
public void print()
{
System.Console.Write(x+" "+y+" "+z+"\n");
}
public Vertex3D()
{
x = y = z = 0;
}
}
Explain c# object arrays pls
The error:
"An unhandled exception of type 'System.NullReferenceException' occurred in sharp_TEST.exe
Additional information: Object reference not set to an instance of an object."
The masterpiece:
class Program {
static void Main() {
Polygon4[] x = new Polygon4[20];
foreach (Polygon4 face in x)
{
face.print();
}
}
}
//////////////////////////////
class Polygon4
{
Vertex3D a, b, c, d;
public Polygon4()
{
a = new Vertex3D();
b = new Vertex3D();
c = new Vertex3D();
d = new Vertex3D();
}
public void print()
{
a.print();
b.print();
c.print();
d.print();
}
}
/////////////////////////////
class Vertex3D
{
float x, y, z;
public void print()
{
System.Console.Write(x+" "+y+" "+z+"\n");
}
public Vertex3D()
{
x = y = z = 0;
}
}
Explain c# object arrays pls