{"id":30,"date":"2024-08-17T04:04:35","date_gmt":"2024-08-17T04:04:35","guid":{"rendered":"https:\/\/techobjects.net\/?p=30"},"modified":"2024-08-17T04:04:35","modified_gmt":"2024-08-17T04:04:35","slug":"c-splitting-csv-looping","status":"publish","type":"post","link":"https:\/\/techobjects.net\/?p=30","title":{"rendered":"C# &#8211; Splitting CSV\/ Looping"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This is a quick example of how to split a string into a string array and how to loop through the results. We then combine the results again changing the delimiter.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>        static void Main(string&#91;] args)\n        {\n            string strToSplit = \"TEST|TEST1|TEST2|TEST3\";\n\n            \/\/Split the string into an Array\n            string&#91;] array = strToSplit.Split('|');\n\n            \/\/Loop through and write each value to the console\n            foreach (string field in array)\n            {\n                Console.WriteLine(field);\n            }\n\n            \/\/Combine values back changing the delimiter to a comma\n            string newStr = string.Join(\",\", array);\n\n            Console.WriteLine(newStr);\n\n            \/\/Use read to keep window open\n            Console.Read();\n\n        }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This is a quick example of how to split a string into a string array and how to loop through the results. We then combine the results again changing the delimiter.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[9,11],"class_list":["post-30","post","type-post","status-publish","format-standard","hentry","category-c","tag-c","tag-looping"],"brizy_media":[],"_links":{"self":[{"href":"https:\/\/techobjects.net\/index.php?rest_route=\/wp\/v2\/posts\/30","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techobjects.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techobjects.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techobjects.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techobjects.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=30"}],"version-history":[{"count":0,"href":"https:\/\/techobjects.net\/index.php?rest_route=\/wp\/v2\/posts\/30\/revisions"}],"wp:attachment":[{"href":"https:\/\/techobjects.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=30"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techobjects.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=30"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techobjects.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=30"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}