c# - Passing an object to another class? -
c# - Passing an object to another class? -
i've been looking constructors, im trying pass object class file, way im doing this:
class programme { static void main(string[] args) { class1 objpls = new class1(); objpls.namearray[0] = "jake"; objpls.namearray[1] = "tom"; objpls.namearray[2] = "mark"; objpls.namearray[3] = "ryan"; echodata form2 = new echodata(objpls); } } class class1 { public string[] namearray = new string[3]; } class echodata { public class1 newobject = new class1(); public echodata(class1 temp) { this.newobject = temp; } // why cant access newobject.namearray[0] example? } problem cant access object array..
what methods of passing objects there? told way , have been experimenting while no avail.
not sure cannot do. illustration code modification works, or @ to the lowest degree compiles.
class echodata { public class1 newobject = new class1(); public echodata(class1 temp) { this.newobject = temp; } // why cant access newobject.namearray[0] example? // kind of access want? public void method1() { newobject.namearray[0] = "jerry"; } } c# oop
Comments
Post a Comment