{"id":108,"date":"2011-03-06T12:10:00","date_gmt":"2011-03-06T18:10:00","guid":{"rendered":"https:\/\/www.chrystalsander.com\/blog\/?p=108"},"modified":"2011-03-06T12:10:00","modified_gmt":"2011-03-06T18:10:00","slug":"convert-comma-delimited-string-to-array-loop","status":"publish","type":"post","link":"https:\/\/www.chrystalsander.com\/blog\/?p=108","title":{"rendered":"Convert Comma-Delimited String To Array &#038; Loop"},"content":{"rendered":"<p><span style=\"color: rgb(0, 153, 0);font-family:courier new;\" >&#8211;set whatever delimiter you want to use:<\/span><br \/><span style=\"font-family:courier new;\">char delimiter = &#8216;,&#8217;;<\/span><\/p>\n<p><span style=\"color: rgb(0, 153, 0);font-family:courier new;\" >&#8211;Get the string you want to turn to an array (in this case, I use the app.config)<\/span><br \/><span style=\"font-family:courier new;\">string s = ConfigurationManager.AppSettings[&#8220;StringToReplace&#8221;];<\/span><\/p>\n<p><span style=\"color: rgb(0, 153, 0);font-family:courier new;\" >&#8211;Declare an array for your string<\/span><br \/><span style=\"font-family:courier new;\">string[] stringToReplace = s.Split(delimiter);<\/span><\/p>\n<p><span style=\"color: rgb(0, 153, 0);font-family:courier new;\" >&#8211;Finally, if you want to loop through your new array:<\/span><br \/><span style=\"font-family: courier new;\">string content = String.Empty;<\/span><\/p>\n<p><span style=\"font-family:courier new;\">for (int j = 0; j <> 0; j++)<br \/><span style=\"font-family:courier new;\">{<\/span><br \/><span style=\"font-family:courier new;\">content = stringToReplace[j];<\/span><br \/><span style=\"font-family:courier new;\">}<\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8211;set whatever delimiter you want to use:char delimiter = &#8216;,&#8217;; &#8211;Get the string you want to turn to an array (in this case, I use the app.config)string s = ConfigurationManager.AppSettings[&#8220;StringToReplace&#8221;]; &#8211;Declare an array for your stringstring[] stringToReplace = s.Split(delimiter); &#8211;Finally, if you want to loop through your new array:string content = String.Empty; for (int j &hellip; <a href=\"https:\/\/www.chrystalsander.com\/blog\/?p=108\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Convert Comma-Delimited String To Array &#038; Loop&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"_links":{"self":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/108"}],"collection":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=108"}],"version-history":[{"count":0,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/108\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}