locked
Create an array from a List<> RRS feed

  • Question

  • User1074108673 posted

    I have the following:
    List<Store> stores1 ;

    How do I then put this List<> data into an array?

    I know I'm missing something with the following:


     string[,] googlemapsarray = new string[stores1[].Friendlyurlname, stores1[].Latitude, stores1[].Longitude];

    Also, since I'm doing this for a google maps array and you know how I will pass this array into javascript once I create it I will be so grateful!

    Thank you!



    Friday, July 1, 2011 9:47 AM

Answers

  • User1401801381 posted

    Hi,

    List have a ToArray() method so

    stores1.ToArray();

     should work

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 1, 2011 9:56 AM

All replies

  • User1401801381 posted

    Hi,

    List have a ToArray() method so

    stores1.ToArray();

     should work

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 1, 2011 9:56 AM
  • User3866881 posted

    I have the following:
    List<Store> stores1 ;

    How do I then put this List<> data into an array?

    I know I'm missing something with the following:


     string[,] googlemapsarray = new string[stores1[].Friendlyurlname, stores1[].Latitude, stores1[].Longitude];

    Also, since I'm doing this for a google maps array and you know how I will pass this array into javascript once I create it I will be so grateful!

    Hello:)

    A very basic way is——

    Store[]stores = new Store[stores1.Count];

    for(int i=0;i<stores.Length;++i)

    {

         stores[i]=stores1[i];

    }

    Sunday, July 3, 2011 10:05 PM