Hi Krish,
My test in Axapta 3.0 SP3 shows different from what you state (as I understand it...) This is my testcode. static void Job1(Args _args) { Array a = new Array(types::Class); Testclass testclass; int i; ; for (i=1; i<100; i++) { testclass = new Testclass(); testclass.setAndGetS(int2str(i)); a.value(i, testclass); testclass = null; } for (i=1; i<100; i++) { testClass = a.value(i); info(testClass.setAndGetS()); } } Now I see that it prints 1 through 99. >From what I read from you I'd expect 99 times 99. So either your problem lies elsewhere in the code (init from the class??) or maybe there is some Axapta setting for this behaviour??? or maybe a version difference. Maybe you can try running my code, see if that works. Here is the code for the class method setAndGetS(). str setAndGetS(str _s = s) { s = _s; return s; } And in the classDeclaration you need to declare a string s. Regards, Nico --- In Axapta-Knowledge-Village@yahoogroups.com, "Bayliss, Barry" <[EMAIL PROTECTED]> wrote: > > Krish, > > > Another way would be to use containers. Your code would be something > like > > Container > Initialise > ( > ) > { > Container Results; > class1 class1; > ; > > while > select table1 > where table1.NoYesId == true > { > class1 = new class1(element); > class1.initmethod(table1); > Results += [Class1.pack()]; > } > Return Results; > } > > > > Barry. > > > -----Original Message----- > From: Krishnendu Roy [mailto:[EMAIL PROTECTED] > Sent: Tuesday, 22 February 2005 3:46 PM > To: Axapta-Knowledge-Village@yahoogroups.com > Subject: [Axapta-Knowledge-Village] Return Array of Class > > > Hi All > I am facing a problem of holding the initialised value of a class when > it is put in an array. > > The coding is done in a form method. Following is the code > > array A1 = new array(types::Class); > class1 class1; > int i = 1; > ; > > while select table1 > where table1.NoYesId == true > { > class1 = new class1(element); //instantiate the class > class1.initmethod(table1); //The method is > responsible to > initialise some values of the > class with the selected record in > table1 > > A1.value(i,class1); //The instantiated & > initialised class is > added as an array element > Class1 = null; > > i++; > > } > > The first loop executed perfectly without any problem. But as soon as > the class1 is getting instantiated & initialised for the second record > the first element in the array got overwritten with the second record. > AS a result at the end of second loop both the elements of the array are > initialised with the second record. And after the execution of the > entire loop the array contains number of elements same as no of selected > records; but none of the elements is initialised. > The cause of the problem may be the array is containing the reference of > the object instead of actual object. As soon as the object is > re-initialised or nullified the values get lost. If that is the reason > how to overcome that. > Any other suggestions will be helpful for me. > > Thanks & regards > Krish > > > > > > > > Sharing the knowledge on Axapta. > Yahoo! Groups Links ------------------------ Yahoo! Groups Sponsor --------------------~--> In low income neighborhoods, 84% do not own computers. At Network for Good, help bridge the Digital Divide! http://us.click.yahoo.com/EpW3eD/3MnJAA/cosFAA/kGEolB/TM --------------------------------------------------------------------~-> Sharing the knowledge on Axapta. Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/Axapta-Knowledge-Village/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/