c# - Access a list data member in a class -
i have class defined like:
public class paths //class point definition { public list<point> points; public color color; public paths(list<point> points, color color) { points = points; color = color; } } in source code make list: list<paths> paths = new list<paths>();
then make list of points: list<point> newpath = null; add stuff it: newpath.add(x, y);
now want newpath inserted in paths list along color. how do this?
then make list of points:
list<point> newpath = null;
no, created variable reference list - need create list:
list<point> newpath = new list<point>(); then can add point object it.
now want
newpathinserted in paths list along color. how do this?
you need create path well:
path path = new path(); path.points = newpath; note following suggestions closer c# conventions:
- use properties instead of fields public members
- start public property names capital letter (e.g.
points) - start parameter names lower-case letter (e.g.
public paths(list<point> points, color color)
Comments
Post a Comment