How to get all elements from an API callHow do I use reflection to call a generic method?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?How do I update the GUI from another thread?How can I get the application's path in a .NET console application?Using LINQ to remove elements from a List<T>Get int value from enum in C#How to loop through all enum values in C#?Get property value from string using reflection in C#Call one constructor from anotherHow to call asynchronous method from synchronous method in C#?

How to publish superseding results without creating enemies

Does deswegen have another meaning than "that is why"?

Is "you will become a subject matter expert" code for "you'll be working on your own 100% of the time"?

Newly created XFS filesystem shows 78 GB used

Why do sellers care about down payments?

I was promised a work PC but still awaiting approval 3 months later so using my own laptop - Is it fair to ask employer for laptop insurance?

Why is the Digital 0 not 0V in computer systems?

Why is my fire extinguisher emptied after one use?

A shy person in a queue

The Planck constant for mathematicians

Planar regular languages

Write a function that returns an iterable object of all valid points 4-directionally adjacent to (x, y)

A medieval fantasy adventurer lights a torch in a 100% pure oxygen room. What happens?

Relocation error involving libgnutls.so.30, error code (127) after last updates

Make 1998 using the least possible digits 8

Can I toggle Do Not Disturb on/off on my Mac as easily as I can on my iPhone?

"Literally" Vs "In the true sense of the word"

Parallel resistance in electric circuits

Why is the T-1000 humanoid?

How do I say "quirky" in German without sounding derogatory?

Stucturing information on this trade show banner

How do I get rid of distortion in pictures of distant objects photographed with a telephoto lens?

Difference in using Lightning Component <lighting:badge/> and Normal DOM with slds <span class="slds-badge"></span>? Which is Better and Why?

Is there a reliable way to hide/convey a message in vocal expressions (speech, song,...)



How to get all elements from an API call


How do I use reflection to call a generic method?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?How do I update the GUI from another thread?How can I get the application's path in a .NET console application?Using LINQ to remove elements from a List<T>Get int value from enum in C#How to loop through all enum values in C#?Get property value from string using reflection in C#Call one constructor from anotherHow to call asynchronous method from synchronous method in C#?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have downloaded some prewritten code that helps me make an API call. The API call gets all end-day stockprices for at time period of my choice.



The problem is that i can only get the stockprice from the latest date to show in the program.



How can i write this code to get alla elements inside the "StockPricesList"?



static void StockPricesForAllInstruments()

ApiClient api = new ApiClient(_apiKey);
InstrumentRespV1 inst = api.GetInstruments();

foreach (var i in inst.Instruments)

StockPricesRespV1 sp = api.GetStockPrices(i.InsId.Value, Convert.ToDateTime("2012-01-01"), DateTime.Today);

StockPriceV1 Kurs = sp.StockPricesList.Last();
Console.WriteLine(Kurs.C);











share|improve this question


























  • What happens if you change StockPriceV1 Kurs = sp.StockPricesList.Last(); to var Kurs = sp.StockPricesList; and change Console.WriteLine(Kurs.C); to foreach (var price in Kurs) Console.WriteLine(price.C); . Also it would help if you link the library you're using.

    – Prix
    Mar 28 at 10:24












  • StockPriceV1 Kurs = sp.StockPricesList.Last(); you are getting only the last element here. Just remove .Last() and you will have a list.

    – fhnaseer
    Mar 28 at 13:08

















0















I have downloaded some prewritten code that helps me make an API call. The API call gets all end-day stockprices for at time period of my choice.



The problem is that i can only get the stockprice from the latest date to show in the program.



How can i write this code to get alla elements inside the "StockPricesList"?



static void StockPricesForAllInstruments()

ApiClient api = new ApiClient(_apiKey);
InstrumentRespV1 inst = api.GetInstruments();

foreach (var i in inst.Instruments)

StockPricesRespV1 sp = api.GetStockPrices(i.InsId.Value, Convert.ToDateTime("2012-01-01"), DateTime.Today);

StockPriceV1 Kurs = sp.StockPricesList.Last();
Console.WriteLine(Kurs.C);











share|improve this question


























  • What happens if you change StockPriceV1 Kurs = sp.StockPricesList.Last(); to var Kurs = sp.StockPricesList; and change Console.WriteLine(Kurs.C); to foreach (var price in Kurs) Console.WriteLine(price.C); . Also it would help if you link the library you're using.

    – Prix
    Mar 28 at 10:24












  • StockPriceV1 Kurs = sp.StockPricesList.Last(); you are getting only the last element here. Just remove .Last() and you will have a list.

    – fhnaseer
    Mar 28 at 13:08













0












0








0








I have downloaded some prewritten code that helps me make an API call. The API call gets all end-day stockprices for at time period of my choice.



The problem is that i can only get the stockprice from the latest date to show in the program.



How can i write this code to get alla elements inside the "StockPricesList"?



static void StockPricesForAllInstruments()

ApiClient api = new ApiClient(_apiKey);
InstrumentRespV1 inst = api.GetInstruments();

foreach (var i in inst.Instruments)

StockPricesRespV1 sp = api.GetStockPrices(i.InsId.Value, Convert.ToDateTime("2012-01-01"), DateTime.Today);

StockPriceV1 Kurs = sp.StockPricesList.Last();
Console.WriteLine(Kurs.C);











share|improve this question
















I have downloaded some prewritten code that helps me make an API call. The API call gets all end-day stockprices for at time period of my choice.



The problem is that i can only get the stockprice from the latest date to show in the program.



How can i write this code to get alla elements inside the "StockPricesList"?



static void StockPricesForAllInstruments()

ApiClient api = new ApiClient(_apiKey);
InstrumentRespV1 inst = api.GetInstruments();

foreach (var i in inst.Instruments)

StockPricesRespV1 sp = api.GetStockPrices(i.InsId.Value, Convert.ToDateTime("2012-01-01"), DateTime.Today);

StockPriceV1 Kurs = sp.StockPricesList.Last();
Console.WriteLine(Kurs.C);








c#






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 13:07









fhnaseer

4,10111 gold badges45 silver badges94 bronze badges




4,10111 gold badges45 silver badges94 bronze badges










asked Mar 28 at 10:20









N1pp3nN1pp3n

11 bronze badge




11 bronze badge















  • What happens if you change StockPriceV1 Kurs = sp.StockPricesList.Last(); to var Kurs = sp.StockPricesList; and change Console.WriteLine(Kurs.C); to foreach (var price in Kurs) Console.WriteLine(price.C); . Also it would help if you link the library you're using.

    – Prix
    Mar 28 at 10:24












  • StockPriceV1 Kurs = sp.StockPricesList.Last(); you are getting only the last element here. Just remove .Last() and you will have a list.

    – fhnaseer
    Mar 28 at 13:08

















  • What happens if you change StockPriceV1 Kurs = sp.StockPricesList.Last(); to var Kurs = sp.StockPricesList; and change Console.WriteLine(Kurs.C); to foreach (var price in Kurs) Console.WriteLine(price.C); . Also it would help if you link the library you're using.

    – Prix
    Mar 28 at 10:24












  • StockPriceV1 Kurs = sp.StockPricesList.Last(); you are getting only the last element here. Just remove .Last() and you will have a list.

    – fhnaseer
    Mar 28 at 13:08
















What happens if you change StockPriceV1 Kurs = sp.StockPricesList.Last(); to var Kurs = sp.StockPricesList; and change Console.WriteLine(Kurs.C); to foreach (var price in Kurs) Console.WriteLine(price.C); . Also it would help if you link the library you're using.

– Prix
Mar 28 at 10:24






What happens if you change StockPriceV1 Kurs = sp.StockPricesList.Last(); to var Kurs = sp.StockPricesList; and change Console.WriteLine(Kurs.C); to foreach (var price in Kurs) Console.WriteLine(price.C); . Also it would help if you link the library you're using.

– Prix
Mar 28 at 10:24














StockPriceV1 Kurs = sp.StockPricesList.Last(); you are getting only the last element here. Just remove .Last() and you will have a list.

– fhnaseer
Mar 28 at 13:08





StockPriceV1 Kurs = sp.StockPricesList.Last(); you are getting only the last element here. Just remove .Last() and you will have a list.

– fhnaseer
Mar 28 at 13:08












1 Answer
1






active

oldest

votes


















0
















replace



var Kurs = sp.StockPricesList.Last();


with



var Kurs = sp.StockPricesList.ToList();

foreach (StockPriceV1 kur in Kurs)

Console.WriteLine(kur.C);






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );














    draft saved

    draft discarded
















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55395149%2fhow-to-get-all-elements-from-an-api-call%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0
















    replace



    var Kurs = sp.StockPricesList.Last();


    with



    var Kurs = sp.StockPricesList.ToList();

    foreach (StockPriceV1 kur in Kurs)

    Console.WriteLine(kur.C);






    share|improve this answer





























      0
















      replace



      var Kurs = sp.StockPricesList.Last();


      with



      var Kurs = sp.StockPricesList.ToList();

      foreach (StockPriceV1 kur in Kurs)

      Console.WriteLine(kur.C);






      share|improve this answer



























        0














        0










        0









        replace



        var Kurs = sp.StockPricesList.Last();


        with



        var Kurs = sp.StockPricesList.ToList();

        foreach (StockPriceV1 kur in Kurs)

        Console.WriteLine(kur.C);






        share|improve this answer













        replace



        var Kurs = sp.StockPricesList.Last();


        with



        var Kurs = sp.StockPricesList.ToList();

        foreach (StockPriceV1 kur in Kurs)

        Console.WriteLine(kur.C);







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 28 at 10:25









        Nomi AliNomi Ali

        1,0253 gold badges21 silver badges41 bronze badges




        1,0253 gold badges21 silver badges41 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.




















            draft saved

            draft discarded















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55395149%2fhow-to-get-all-elements-from-an-api-call%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해