String array to csv
convert-string-array-to-csv.aspx
<%@ Page Language="C#" AutoEventWireup="true"%>
<%@ Import Namespace="System.IO" %>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
string[] colors = new string[]
{
"red",
"green",
"yellow",
"blue",
"pink",
};
Label1.Text = "colors array.........<br />";
foreach (string s in colors)
{
Label1.Text += s + "<br />";
}
string commaseparatedstring = String.Join(",", colors);
string filename = Server.MapPath("csv.txt");
using (StreamWriter file = new StreamWriter(filename))
{
file.Write(commaseparatedstring);
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>c# example - string array to csv</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:DarkBlue; font-style:italic;">
c# example - string array to csv
</h2>
<hr width="550" align="left" color="LightBlue" />
<asp:Label
ID="Label1"
runat="server"
Font-Size="Large"
>
</asp:Label>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
Text="convert string array to csv"
OnClick="Button1_Click"
Height="40"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>


- How to convert a byte array to a string
- How to sort array elements in descending order
- How to copy elements in one array to another array
- How to check if an int array contains a value
- How to make array contains case insensitive
- How to add a new item in an existing array
- How to add a new item at the end of an existing array
- How to convert a string array to a comma separated string
- How to perform binary search on an array
- How to create an array of objects