Michelle Oratil

Michelle Oratil

  • NA
  • 1
  • 1.1k

Accessing array elements with dynamic size

Nov 19 2013 3:56 AM
Hi,

So I have an array named Services[] which is a return from a web service method.
I want to access its elements. Currently I have:


                            
                            Services[] x = new Services[5];

                            x = getServicesLibrary();

                            for (int i = 0; i < x.Length; i++)
                           {
                                
                                label1.text = x[i].servicecode.ToString() + "->" + x[i].servicedesc.ToString() + "  ");

                           }


and the result is:  1->Laboratory  

I am getting the first element only. How can I get all the elements of the array?
And also, is it possible to declare a dynamic size of the array? Since it is coming form a web service, I am assuming that the ServiceLibrary will expand.

Thank you so much!


Answers (2)