String to csv
string-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 birds = "Sandpiper Plover Tern Skua Puffin";
string result = birds.Replace(' ', ',');
Label1.Text = "string of birds............<br />";
Label1.Text += birds;
Label1.Text += "<br /><br />string to comma separated list............<br />";
Label1.Text += result;
string appPath = Request.PhysicalApplicationPath;
string filePath = appPath + "birds.csv";
//string to physical csv file
using (StreamWriter swriter = new StreamWriter(filePath))
{
swriter.Write(result.ToString());
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>c# example - string to csv</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:MidnightBlue; font-style:italic;">
c# example - string to csv
</h2>
<hr width="550" align="left" color="Gainsboro" />
<asp:Label
ID="Label1"
runat="server"
Font-Size="Large"
>
</asp:Label>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
Text="string to csv"
OnClick="Button1_Click"
Height="40"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>


- How to convert a string to uppercase characters
- How to convert a string to lowercase characters
- How to join an array elements into a new string
- How to compare two strings
- How to convert a string to decimal
- How to convert a delimited string to a dictionary
- How to convert a string to a double array
- How to convert a string to a guid
- How to convert a string to a generic list
- How to get bytes from a string