Home > Net >  C # : after using the constructor of a class, why my instance is still null
C # : after using the constructor of a class, why my instance is still null

Time:09-16

Bosses, please, I use the List in the class, met new after the null may not be the condition of the element is added in the member List
//node class node
Public class node
{
Public int id;//record id number
Public PointF pos_;
Public List Linked_arcs_;//as is expressed as the starting point, a negative end said
}
//arc arc
Public class arc
{
Public arc ()
{
P_list_=new List (a);
}
Public arc (double x, double y)
{
PointF pot=new PointF ();
Pot. X=the Convert. ToSingle (X);
Pot. Y=the Convert. ToSingle (Y);
P_list_=new List (a);
P_list_. Add (pot);
}
Public arc (PointF p)
{
P_list_=new List (a);
P_list_. Add (p);
}
Public arc (List P_list)
{
P_list_=p_list;
}

Public List P_list_;//record point
//store left polygon, right polygon, id, number of points, the start node and end node number
Public int left_polygon right_polygon, id, count, from_node, to_node;
}
//polygon polygon
Public class polygon
{
Public List Islands_;//record island
Public List P_list_;//record point
Public List Arc_list_;//record segment number, reverse negative
//record polygon id and outsourcing rectangular border
Public int id, x_max x_min y_max, y_min;
}
//topology structure topology
Public class topology
{
Public topology ()
{
List Nodes_=new List (a);//storage node
Nodes_. Add (new node ());//test line, even if this line, after the new topology is still null, nodes_ List still can't add elements such as
List Arcs_=new List (a);//store segment
List Polygons=new List (a);//store polygons
Polygon outer_polygon=new polygon ();
}

Public List Nodes_;//storage node
Public List Arcs_;//store segment
Public List Polygons;//store polygons
Public polygon outer_polygon;//the polygon
}

In the topology a_topology=new topology (); After the break point, a_topology still is null, can not add elements in the List members, is this why?

CodePudding user response:

But shall not apply to the constructor, directly behind the members defined initialization can

CodePudding user response:

Understand, their mentally disabled
  •  Tags:  
  • C #
  • Related