John Riker

John Riker

  • NA
  • 85
  • 16.1k

Loop two associated string arrays?

Nov 10 2020 9:36 AM
I have two sets of data I have in my C# config file that are related to each other.  So for example.
 
Config:
  1. <add key="shownames" value="Show 1 Name,Show 2 Name"/>  
  2. <add key="showurls" value="https://URL1,https://URL2"/>  
 So then I call read them in with: 
  1. string[] ShowNames = ConfigurationManager.AppSettings["shownames"].Split(',').Select(s => s.Trim()).ToArray();   
  2. string[] ShowUrls = ConfigurationManager.AppSettings["showurls"].Split(',').Select(s => s.Trim()).ToArray();    
 Then in theory I start reading in shownames
  1. foreach (string shownames in ShowNames)  
 So then I would reference the current value of shownames with:
  1. searchListRequest.ChannelId = shownames;  
 But how do I reference the matching value for showurls?  Do I need to reference it as a loop value like showurls[1] or something?
 
Thanks.
 
JR 
 

Answers (3)