String to ip address
string-to-ip-address.aspx
<%@ Page Language="C#" AutoEventWireup="true"%>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
//this line create a string variable.
string stringOfIPAddress = "127.0.0.1";
Label1.Text = "string of ip address............<br />";
Label1.Text += stringOfIPAddress;
//parse/convert string to ip address
System.Net.IPAddress ip = System.Net.IPAddress.Parse(stringOfIPAddress);
Label1.Text += "<br /><br />ip address............<br />";
Label1.Text += ip;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>c# example - string to ip address</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:MidnightBlue; font-style:italic;">
c# example - string to ip address
</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 ip address"
OnClick="Button1_Click"
Height="40"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>
- How to replace a substring of a string
- How to format a string as a phone number
- How to format a decimal string as percentage value
- String contains ignorecase
- How to format a string as datetime yyyyMMdd
- How to format a string as currency
- How to get bytes from a string
- How to convert a string to an int list
- How to convert a string to an int array
- How to split a string to key value pairs