String to ascii
string-to-ascii.aspx
<%@ Page Language="C#" AutoEventWireup="true"%>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
//this section create a string variable.
string birds = "Smew. Penguin.";
Label1.Text = "string of birds..................<br />";
Label1.Text += birds;
//this line convert string to byte array.
byte[] bytes = Encoding.ASCII.GetBytes(birds);
Label1.Text += "<br /><br />ASSCII codes of string characters........";
foreach(byte b in bytes)
{
//represent the ASCII code of characters.
Label1.Text += "<br />" + b;
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>c# example - string to ascii</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:MidnightBlue; font-style:italic;">
c# example - string to ascii
</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 ascii"
OnClick="Button1_Click"
Height="40"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>
- How to compare two strings by ignoring case
- String split and join
- How to split a string on newlines
- How to format a string as negative currency
- How to format a string as a date
- How to check whether a string starts with number
- How to check whether a string starts with letter
- How to convert a string to a bool
- How to convert a string to stream
- How to convert a string to an arraylist