TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
John Riker
NA
85
15.8k
Array, loop, what # am I on?
Mar 12 2021 1:37 PM
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
}
}
Now here's the problem I'm trying to solve. On the part that says "write no data". I am currently outputting that no shows were found but not what show it is. Not a big deal but still nice to see. So I have this:
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
Reply
Answers (
1
)
Cofoundry CMS in Asp.net core.
SharePoint 2016 500 (Internal Server Error) When uploading