Hello everybody,
I am new on this forum. I register today as I started developing an application in c# and I am having some problems...
I would thus appreciate advices from most experimented developers
Here is the kind of code parts where I have some trouble:
I noticed that when I am clearing the ArrayList "listMain". I am also deleting the value in the object1 "o1" 's field... I suspect it to be related to my use of reference. But can't find a solution to that problem. Any help appreciatedCode:class object1 { public ArrayList mChiffres; public object1(ArrayList chiffres) { this.mChiffres = chiffres; } } class Program { int[] numbers1 = new int[9] {1,2,3,4,5,6,7,8,9}; ArrayList list = new ArrayList(); public void method1(int i, ref ArrayList listMain) { if (numbers1[i] < 9) { listMain.Add(numbers1[i]); } else { object1 o1 = new object1(listMain); list.Add(o1); listMain.Clear(); } } static void Main(string[] args) { int i=0; ArrayList listMain = new ArrayList(); while(i<10) { method1(i, ref listMain); i++; } } }!
btw have to use reference and a separate method1 (for the curious it's just that I am planning to have a recursive call to method1 inside method1 later)
Thank you in advance





!
Reply With Quote
