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;
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#
add a comment
|
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#
What happens if you changeStockPriceV1 Kurs = sp.StockPricesList.Last();tovar Kurs = sp.StockPricesList;and changeConsole.WriteLine(Kurs.C);toforeach (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
add a comment
|
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#
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#
c#
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 changeStockPriceV1 Kurs = sp.StockPricesList.Last();tovar Kurs = sp.StockPricesList;and changeConsole.WriteLine(Kurs.C);toforeach (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
add a comment
|
What happens if you changeStockPriceV1 Kurs = sp.StockPricesList.Last();tovar Kurs = sp.StockPricesList;and changeConsole.WriteLine(Kurs.C);toforeach (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
add a comment
|
1 Answer
1
active
oldest
votes
replace
var Kurs = sp.StockPricesList.Last();
with
var Kurs = sp.StockPricesList.ToList();
foreach (StockPriceV1 kur in Kurs)
Console.WriteLine(kur.C);
add a comment
|
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
replace
var Kurs = sp.StockPricesList.Last();
with
var Kurs = sp.StockPricesList.ToList();
foreach (StockPriceV1 kur in Kurs)
Console.WriteLine(kur.C);
add a comment
|
replace
var Kurs = sp.StockPricesList.Last();
with
var Kurs = sp.StockPricesList.ToList();
foreach (StockPriceV1 kur in Kurs)
Console.WriteLine(kur.C);
add a comment
|
replace
var Kurs = sp.StockPricesList.Last();
with
var Kurs = sp.StockPricesList.ToList();
foreach (StockPriceV1 kur in Kurs)
Console.WriteLine(kur.C);
replace
var Kurs = sp.StockPricesList.Last();
with
var Kurs = sp.StockPricesList.ToList();
foreach (StockPriceV1 kur in Kurs)
Console.WriteLine(kur.C);
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
add a comment
|
add a comment
|
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
What happens if you change
StockPriceV1 Kurs = sp.StockPricesList.Last();tovar Kurs = sp.StockPricesList;and changeConsole.WriteLine(Kurs.C);toforeach (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