ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Convert genetic List to comma separated string enclosed within quotes using C# and VB.Net<p>You need to use the foreach loop.</p> <p><span style="text-decoration: underline;">C#</span></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { List&lt;string&gt; list1 = new List&lt;string&gt;(); list1.Add(&#34;option1&#34;); list1.Add(&#34;option2&#34;); list1.Add(&#34;option3&#34;); string allProductId = &#34;&#34;; foreach (string s in list1) { allProductId += &#34;&#39;&#34; + s + &#34;&#39;, &#34;; } allProductId = allProductId.Remove(allProductId.Length - 2); }</pre> <p><span style="text-decoration: underline;">VB.Net</span></p> <pre class="brush: vb">Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load Dim list1 As New List(Of String)() list1.Add(&#34;option1&#34;) list1.Add(&#34;option2&#34;) list1.Add(&#34;option3&#34;) Dim allProductId As String = &#34;&#34; For Each s As String In list1 allProductId += (Convert.ToString(&#34;&#39;&#34;) &amp; s) + &#34;&#39;, &#34; Next allProductId = allProductId.Remove(allProductId.Length - 2) End Sub</pre>https://www.aspforums.net:443/Threads/866059/Convert-genetic-List-to-comma-separated-string-enclosed-within-quotes-using-C-and-VBNet/https://www.aspforums.net:443/Threads/866059/Convert-genetic-List-to-comma-separated-string-enclosed-within-quotes-using-C-and-VBNet/Fri, 31 Oct 2014 02:48:55 GMT