I am trying to avoid another variable counting where I'm at in a loop, but need to find out something and trying to find a work around.
So here's the deal. I have a comma separated list of values in a config file. Read in the values like this:
string[] JSONShowUrls = ConfigurationManager.AppSettings["jsonshowurls"].Split(',').Select(s => s.Trim()).ToArray();
So I loop thru those
- foreach (string showsurls in JSONShowUrls)
- {
- if (rootObject.tiles != null) // Check if the show returned any data
- {
- do something
- }
- else
- {
- write no data
- }
- }
string[] JSONShowNames = ConfigurationManager.AppSettings["jsonshownames"].Split(',').Select(s => s.Trim()).ToArray();
So this has a list of the names of each show in case it's needed. It's in the same order as the prior config value. So in theory whatever # in the loop
- foreach (string showsurls in JSONShowUrls)
is, the name of the show would be in that same spot in JSONShowNames above. Any way to easily pull the right array number off JSONShowNames if the current array of JSONShowUrls is empty?
Hope this makes some sense.
Thanks.
JR
Amit GuptaPosted Mar 13, 2021, 4:00 AM